Hi ,
I am new to
VB myself but I have a vague idea as to how you can validate text fields for numerics/alpha numerics. Ill give you the code to validate for characters. Im not sure about how to validate an email address.
one can validate a text field using the KEYDOWN method of the text box to check for the ASCII codes of each Key which is pressed while typing in the text box. heres the code.
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
'De-Comment the next line to get ascii code of keys
'MsgBox "Ascii code of the key you pressed is " & KeyCode
'if user presses the shift,caps lock , backspace ,
'space,enter or the delete key then ignore check
If KeyCode = 20 Or KeyCode = 16 Or KeyCode = 8 Or KeyCode = 32 Or KeyCode = 13 Or KeyCode = 46 Then
Exit Sub
End If
'If user presses anything other than a character ie. Ascii code 65-90 then error
If KeyCode < 65 Or KeyCode > 90 Then
MsgBox "Error! only characters"
Text1.Text = ""
End If
End Sub
if anyone knows how to validate an Email address please enlighten me :)