Visual Basic Programming Code Examples
Visual Basic > Forms Code Examples
Limit input in a textbox to certain characters
Limit input in a textbox to certain characters
Function LimitTextInput(source) as String
'put the next line in the Textbox_KeyPress event
'KeyAscii = LimitTextInput(KeyAscii)
'change Numbers with any other character
Const Numbers$ = "0123456789."
'backspace =8
If source <> 8 Then
If InStr(Numbers, Chr(source)) = 0 Then
LimitTextInput = 0
exit Function
end If
end If
LimitTextInput = source
End Function
Return