Variable Question (SOLVED)
3 posts
• Page 1 of 1
Variable Question (SOLVED)
In VB is there a way to tell if a variable contains numbers or letters??? I want to display an error message if the user enters letters instead of numbers instead of having a program error whenever this happens.
Like
- Code: Select all
If VAR contains numbers Then
TextBox1.Text = VAR * 3
ElseIf VAR contains letters Then
Dim frm_error as new Error_Message
frm_error.show
Obviously this is incorrect code, I was trying to make it more clear what I wanted.
Mac OS 10.6.7 - Personal
Ubuntu Server 11.04 - Server
In VB6 I used the IsNumeric function of the String object.
You could test it with something like :
- Code: Select all
Dim S As String
S = "123gh"
If IsNumeric(S) Then MsgBox "Yes", vbOKOnly
If Not IsNumeric(S) Then MsgBox "No", vbOKOnly
End Sub
If this doesn't work for you or it's not what you need I can post a Sub that verifies the string character by character - like a self made IsNumeric function. Just let me know!
Best wishes,
John!
3 posts
• Page 1 of 1
Return to HTML, CSS, and Scripts
Who is online
Users browsing this forum: No registered users and 1 guest