BUG: KeyAscii Behavior Different with DBCombo Control (140353)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
This article was previously published under Q140353 SYMPTOMS
Setting 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.
WORKAROUND
To 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 Sub
You 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.
STATUS
Microsoft 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.
Modification Type: | Minor | Last Reviewed: | 6/23/2005 |
---|
Keywords: | kbbug KB140353 |
---|
|