This code will help one to control the input at runtime in vb.
All the cases mentioned in this code are the ascii values......
For more customization you can use
Private Sub text1_KeyPress(KeyAscii As Integer)
If Text2.MaxLength = True Then
MsgBox "Can't exceed more than 30 characters"
End If
Select Case KeyAscii
Case Asc(" ")
Case 65 To 90
Case 97 To 122
Case 48 To 57
Case 32
Case 13
Case 8
Case 127
Case Else
MsgBox "Invalid Input", vbOKOnly + vbExclamation
KeyAscii = 0
End Select
End Sub
All the cases mentioned in this code are the ascii values......
For more customization you can use
Private Sub text1_KeyPress(KeyAscii As Integer)
If Text2.MaxLength = True Then
MsgBox "Can't exceed more than 30 characters"
End If
Select Case KeyAscii
Case Asc(" ")
Case 65 To 90
Case 97 To 122
Case 48 To 57
Case 32
Case 13
Case 8
Case 127
Case Else
MsgBox "Invalid Input", vbOKOnly + vbExclamation
KeyAscii = 0
End Select
End Sub
Comments
Post a Comment