hawaiian1975
Programmer
I am trying to validate data in a text box. Basically the data in the text box will be nothing but numbers. Letters and anything else will be invalid data. Here is the code that I have so far:
Private Sub mnuDataValidate_Click()
Const conBtns As Integer = vbOK + vbExclamation + vbDefaultButton1 + vbApplicationModal
Dim intRetVal As Integer
Select Case txtWheel(0).Text
Case "A" To "Z"
intRetVal = MsgBox("Invalid Data", conBtns, "Data Entry Form"
txtWheel(0).Text = ""
Case "a" To "z"
intRetVal = MsgBox("Invalid Data", conBtns, "Data Entry Form"
txtWheel(0).Text = ""
Case "~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", "", "-", "_", "+", "=", "|", "\"
intRetVal = MsgBox("Invalid Data", conBtns, "Data Entry Form"
txtWheel(0).Text = ""
End Select
Select Case txtWheel(1).Text
Case "A" To "Z"
intRetVal = MsgBox("Invalid Data", conBtns, "Data Entry Form"
txtWheel(1).Text = ""
Case "a" To "z"
intRetVal = MsgBox("Invalid Data", conBtns, "Data Entry Form"
txtWheel(1).Text = ""
Case "~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", "", "-", "_", "+", "=", "|", "\"
intRetVal = MsgBox("Invalid Data", conBtns, "Data Entry Form"
txtWheel(1).Text = ""
End Select
End Sub
If I was to type 123a4 the data won't be validated, but if I was to type Aaaa, the data will be validated. How do I write this so that anything other than numbers is invalid?
Private Sub mnuDataValidate_Click()
Const conBtns As Integer = vbOK + vbExclamation + vbDefaultButton1 + vbApplicationModal
Dim intRetVal As Integer
Select Case txtWheel(0).Text
Case "A" To "Z"
intRetVal = MsgBox("Invalid Data", conBtns, "Data Entry Form"
txtWheel(0).Text = ""
Case "a" To "z"
intRetVal = MsgBox("Invalid Data", conBtns, "Data Entry Form"
txtWheel(0).Text = ""
Case "~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", "", "-", "_", "+", "=", "|", "\"
intRetVal = MsgBox("Invalid Data", conBtns, "Data Entry Form"
txtWheel(0).Text = ""
End Select
Select Case txtWheel(1).Text
Case "A" To "Z"
intRetVal = MsgBox("Invalid Data", conBtns, "Data Entry Form"
txtWheel(1).Text = ""
Case "a" To "z"
intRetVal = MsgBox("Invalid Data", conBtns, "Data Entry Form"
txtWheel(1).Text = ""
Case "~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", "", "-", "_", "+", "=", "|", "\"
intRetVal = MsgBox("Invalid Data", conBtns, "Data Entry Form"
txtWheel(1).Text = ""
End Select
End Sub
If I was to type 123a4 the data won't be validated, but if I was to type Aaaa, the data will be validated. How do I write this so that anything other than numbers is invalid?