what if in a text box i dont want any numbers to be typed in and only 2 letters??? how can i do this??
Printable View
what if in a text box i dont want any numbers to be typed in and only 2 letters??? how can i do this??
I'm not sure what you are asking about, but if you don't want numbers and you allow user to type any two letters then use this:
Also set TextBox's MaxLength property to 2Code:Private Sub Text1_KeyPress(KeyAscii As Integer)
If IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
End If
End Sub
~~~~~~~~~~~
Or if you know what two letters you want the user to enter (for example if you want them to type C for Credit and D for Debit) and you want the user to enter only one letter on a time then use this:
And set MaxLength Property to 1Code:Private Sub Text1_KeyPress(KeyAscii As Integer)
If (Chr(KeyAscii)) <> ["Enter Your First Character"] or (Chr(KeyAscii)) <> _
["Enter Your Second Character"] Then
KeyAscii = 0
End If
End Sub
~~~~~~~~~~~~~~~~~~
------------------
Visual Basic Programmer (at least I want to be one)
------------------
PolComSoft
You will hear a lot about it.
[This message has been edited by QWERTY (edited 12-04-1999).]