dayle Posted November 10, 2002 Share Posted November 10, 2002 hey guys i need your help in vb i have a form with a text box and a button textbox name=textbox5 buttonname=button1 on the click event of the button i wanna check for a valid format of an email address on writing this code it builds but wont function the way i want it k = Mid(TextBox5.Text, 1, Len(TextBox5.Text)) z = k Like "[a-zA-Z0-9][@][a-zA-Z0-9][.][a-zA-Z]" If z = False Then MsgBox("invalid email") End If ive even tried this validation for the 2nd line z = k Like "[a-zA-Z0-9]*""[@]{1}""[a-zA-Z0-9]*""[.]{1}"[a-zA-Z]*" could you please help me out thanks :D Link to comment Share on other sites More sharing options...
0 dayle Posted November 10, 2002 Author Share Posted November 10, 2002 hello can someone please help me Link to comment Share on other sites More sharing options...
0 0sit0 Posted November 10, 2002 Share Posted November 10, 2002 i wish i could help you but i started visual basic this semester and dunno much about that stuff :unsure: Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted November 11, 2002 Share Posted November 11, 2002 Your pattern is incorrect. This one works. *@*.[a-zA-Z][a-zA-Z][a-zA-Z] when you put [a-z], it is only for one character. Just outta curiosity, why use the mid to store the textbox string in a variable string? It'll work if you just have it like so... z = textbox5 Like *@*.[a-zA-Z][a-zA-Z][a-zA-Z] . . . etc. as long as the email addy is the only thing in the textbox. Link to comment Share on other sites More sharing options...
0 dayle Posted November 14, 2002 Author Share Posted November 14, 2002 Your pattern is incorrect.This one works. *@*.[a-zA-Z][a-zA-Z][a-zA-Z] when you put [a-z], it is only for one character. Just outta curiosity, why use the mid to store the textbox string in a variable string? It'll work if you just have it like so... z = textbox5 Like *@*.[a-zA-Z][a-zA-Z][a-zA-Z] . . . etc. as long as the email addy is the only thing in the textbox. good point bout the mid..thanx for the syntax Link to comment Share on other sites More sharing options...
0 dayle Posted November 14, 2002 Author Share Posted November 14, 2002 hey dude the code doesnt work..its highlighting the first * Link to comment Share on other sites More sharing options...
0 aemon Posted November 14, 2002 Share Posted November 14, 2002 This seems to work Dim IsEmailValid As Boolean IsEmailValid = txtEmailAddress.Text Like "*@*.[a-zA-Z][a-zA-Z][a-zA-Z]" If Not IsEmailValid Then MsgBox ("invalid email") End If Link to comment Share on other sites More sharing options...
0 dayle Posted November 14, 2002 Author Share Posted November 14, 2002 thanks guys for the help...it works :D Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted November 14, 2002 Share Posted November 14, 2002 Sorry about omitting the quotes. :blush: Link to comment Share on other sites More sharing options...
0 twist Posted November 14, 2002 Share Posted November 14, 2002 won't that say that emails that don't have a 3 letter ending are invalid? wouldn't it say an email like blah@nbnet.nb.ca is invalid? just wondering Link to comment Share on other sites More sharing options...
0 Lomex Posted November 14, 2002 Share Posted November 14, 2002 won't that say that emails that don't have a 3 letter ending are invalid?wouldn't it say an email like blah@nbnet.nb.ca is invalid? just wondering Yes it will Link to comment Share on other sites More sharing options...
0 Steven Posted November 14, 2002 Share Posted November 14, 2002 what about having the PERIOD before the @ sign? wouldn't this be an issue tooooo ? :huh: john.jacob.jinglehighmer.shmich.james.donavin@jumpandfreinds.us.gov of and DON"T FORGET TO TRUNCATE SPACES would that be a problem email vailidation aint simple. Link to comment Share on other sites More sharing options...
0 twist Posted November 14, 2002 Share Posted November 14, 2002 it should be checking for the last instance of the . then to see if its at least two chars long. then see if the chars are valid. there are a few chars that cannot be in an email address. its more then single line test. Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted November 15, 2002 Share Posted November 15, 2002 (edited) Definitely a lot of cases to check. Email addys can't contain special chars, spaces, or control chars. The domain name could also be an IP, a special case, but a case nonetheless. http://www.ietf.org/rfc/rfc0822.txt?number=822 It's too bad VB 6 doesn't have regular expressions. Link to comment Share on other sites More sharing options...
0 aemon Posted November 15, 2002 Share Posted November 15, 2002 Actually Weenur, you can use regular expressions in VB6. Just add a reference to Microsoft VBScript Regular Expressions 5.5 Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted November 15, 2002 Share Posted November 15, 2002 Well, that should make things easy for you. I think it would be more robust than using the Like function. Link to comment Share on other sites More sharing options...
0 dayle Posted November 15, 2002 Author Share Posted November 15, 2002 actually i just need it in the a@a.com pattern if my faculty asks for a@a.co.in and stuff then ill just list them in a combobox or something like that :) Link to comment Share on other sites More sharing options...
Question
dayle
hey guys i need your help in vb
i have a form with a text box and a button
textbox name=textbox5
buttonname=button1
on the click event of the button i wanna check for a valid format of an email address
on writing this code it builds but wont function the way i want it
k = Mid(TextBox5.Text, 1, Len(TextBox5.Text))
z = k Like "[a-zA-Z0-9][@][a-zA-Z0-9][.][a-zA-Z]"
If z = False Then
MsgBox("invalid email")
End If
ive even tried this validation for the 2nd line
z = k Like "[a-zA-Z0-9]*""[@]{1}""[a-zA-Z0-9]*""[.]{1}"[a-zA-Z]*"
could you please help me out
thanks :D
Link to comment
Share on other sites
16 answers to this question
Recommended Posts