Type checking in VB
Type checking in VB
(OP)
How do you type check in VB?
Suppose I have a Textbox which I want to accept only integers, and give error otherwise. Is there a built in function that lets you set the textbox data type?
Thanks.
Suppose I have a Textbox which I want to accept only integers, and give error otherwise. Is there a built in function that lets you set the textbox data type?
Thanks.
jevakil@mapdi.com
One nuclear bomb can ruin your whole day.





RE: Type checking in VB
If isnumeric(textbox.text) then
'action if numeric
Else
msgbox "Must enter a numeric value"
textbox.setfocus
End If
I hope this helps you out
RE: Type checking in VB
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8, 46, 48 To 57 'backspace, dec point & numbers only
Exit Sub
Case Else
KeyAscii = 0
Beep
End Select
End Sub
You still need to stop cut&paste though
Good Luck
johnwm
RE: Type checking in VB
Regards,
Javad
jevakil@mapdi.com
One nuclear bomb can ruin your whole day.