K
Kay
Hi all,
I created a function to limit only number(dot/del etc are ok) can be entered
into a text box. If an invalid character is entered I simply want to cancel
what is entered - this part works but, if a VALID character is entered it
produce "Specified cast is not valid"... can you tell why? Here's my code:
Function OnlyNumber(ByRef e As System.Windows.Forms.KeyPressEventArgs)
As Boolean
Dim iAsc As Integer
e.Handled = False
iAsc = Asc(e.KeyChar)
Select Case iAsc
Case 8
'user press backspace, do nothing
Case 127
'user press del, do nothing
Case 48 To 57
'valid key, do nothing from 0-9
Case 44
'valid key, comma
Case 46
'valid key, dot
Case Else
'other invalid key
OnlyNumber = True
End Select
End Function
<<<<<<<
Thanks!
Kay
I created a function to limit only number(dot/del etc are ok) can be entered
into a text box. If an invalid character is entered I simply want to cancel
what is entered - this part works but, if a VALID character is entered it
produce "Specified cast is not valid"... can you tell why? Here's my code:
Function OnlyNumber(ByRef e As System.Windows.Forms.KeyPressEventArgs)
As Boolean
Dim iAsc As Integer
e.Handled = False
iAsc = Asc(e.KeyChar)
Select Case iAsc
Case 8
'user press backspace, do nothing
Case 127
'user press del, do nothing
Case 48 To 57
'valid key, do nothing from 0-9
Case 44
'valid key, comma
Case 46
'valid key, dot
Case Else
'other invalid key
OnlyNumber = True
End Select
End Function
<<<<<<<
Thanks!
Kay