Hi,
I have a Textfield and i want it to accept only Digits 0-9, Backslash, Delete, Tab, Right and Left Key. How to handle this?
[h]Sample[/h]
Select Case Key
Case Chr(8)
Return False
Else
Return True
End Select
Won’t work!
Hi,
I have a Textfield and i want it to accept only Digits 0-9, Backslash, Delete, Tab, Right and Left Key. How to handle this?
[h]Sample[/h]
Select Case Key
Case Chr(8)
Return False
Else
Return True
End Select
Won’t work!
[code]Event KeyDown(key As String) As Boolean
Const LOWEST_DIGIT = 48
Const HIGHEST_DIGIT = 48
Const BACK_SLASH = 92
Const DELETE = 127
Const TAB = 9
Const LEFT = 28
Const RIGHT = 29
Select Case Asc(key)
Case LOWEST_DIGIT To HIGHEST_DIGIT, BACK_SLASH, DELETE, TAB, LEFT, RIGHT
Return False
Else
Beep()
Return True
End
End[/code]
The keycode constants depend on the OS and the language settings of its user.
Cool Eli Ott. And there is no way to do have Platform Independent Solution?
All printable characters are cross-platform. I don’t know about arrow keys and the like.
In Xojo, AFAIK arrow keys are cross platform between Mac and Windows. Probably Linux as well.