PDA

Click to See Complete Forum and Search --> : how to validate email in a text box


cloudlck
Jan 28th, 2000, 10:23 AM
hi..
i am a basic vb learner.. i have a problem about the email validation.. actually inside my program have atext box who let user to key in email.. but some of the invalid field like double "@" in a field or "@clouclck.com" and have alot of invalid field.. so. can somebody help me to fix this validation by showing me source code.. i will appreciate it.. thx.. hope hear from u soon..!

OneSource
Jan 28th, 2000, 11:20 AM
Hi cloudlck,

Here's some email validation code. I included everything I could think of that would need to be in an email address. However, you should easily be able to add more validation after checking out the code below.

In order to try it out, create a new project with a text box and a command button.Option Explicit

Private Sub Command1_Click()
If Text1 = "" Or Left(Text1, 1) = "@" Or InStr(Text1, "@") = 0 Or UCase(Right(Text1, 3)) <> "COM" Or InStr(Text1, "@@") > 0 Then
MsgBox "Invalid Email Address.", vbCritical, "Try Again."
Text1.SetFocus
Else
MsgBox "Valid Email Address."
End If
End Sub
All the best.

------------------
OneSource
The truth may be out there, but it's in here too!.


[This message has been edited by OneSource (edited 01-29-2000).]

cloudlck
Jan 28th, 2000, 11:45 AM
thanks one source... the code is work on my module.. thx.. nice to meet you..