BUG: KeyAscii Behavior Different with DBCombo ControlLast reviewed: October 3, 1996Article ID: Q140353 |
The information in this article applies to:
SYMPTOMSSetting the KeyAscii parameter to 0 in a KeyPress event of a DBCombo control shows the character being typed. The expected behavior is the same as a TextBox control--characters being typed should not appear in the DBCombo control.
WORKAROUNDTo work around this problem, place a TextBox control over the top of the text portion of the DBCombo control. Add code shown below to the KeyPress event of the TextBox control to accept and reject the appropriate characters. If you would like typed characters not to appear, then use the normal method of setting the KeyPress parameter of the TextBox control to 0. All other characters from the TextBox control can be passed through the DBCombo control by appending the characters to the Text property of the DBCombo control. The following code example shows only numeric values in the TextBox control and passes those values to the Text property of the DBCombo control.
Private Sub Text1_KeyPress(KeyAscii As Integer) If (KeyAscii < 48) Or (KeyAscii > 57) Then KeyAscii = 0 Else DBCombo1.Text = Text1.Text & Chr$(KeyAscii) End If End SubYou can also add code to exactly mimic the functionality of an empty TextBox control. For example, you can add code to allow the user to backspace and also to ensure that changes in the DBCombo control are reflected in the TextBox control.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
Steps to Reproduce Behavior
|
Additional reference words: buglist4.00 4.00 DBCombo vb4all vb4win combobox
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |