Hi All today i will show you a Funtion a made to validate email addresses in a string ok im not good at making tutorials so i hope you understand the most![]()
ok the funtion looks like this
HTML Code:Public Function ValEmail(mail As String) If Left(mail, 1) = "@" Then GoTo NotValide ElseIf Right(mail, 1) = "@" Then GoTo NotValide ElseIf InStr(1, mail, "@") = False Then MsgBox "The @ is Missing!" ElseIf InStr(1, mail, ".") = False Then GoTo NotValide ElseIf Right(mail, 1) = "." Then GoTo NotValide ElseIf Left(mail, 1) = "." Then GoTo NotValide 'Not Valide NotValide: MsgBox "This is Not a Valide Email Address!" End If End Function
first part of the funtion like u see is
So this part looks for the @ on the first place of the string if the string is in the format @somthingCode:If Left(mail, 1) = "@" Then GoTo NotValide
then its not valide so that the funtion calls the goto funtion and moves to NotValide
Next Part like you see is
its the same as above but this looks from the right if the first char is a @ its again a Invalide Email and againCode:ElseIf Right(mail, 1) = "@" Then GoTo NotValide
we call goto
Next Part is
This is a easy if stament we use the instr funtion to make a bool statment dont know the right word for itCode:ElseIf InStr(1, mail, "@") = False Then MsgBox "The @ is Missing!"
in english hope you know what i mean so if the instr funtion returns false we know that the @ is missing
and this is again not a valide email address and we then call a msgbox to tell that the @ is missing
Next Part is
This is again a bool statment that looks for what the funtion returns if instr funtion returns falseCode:ElseIf InStr(1, mail, ".") = False Then GoTo NotValide
we know that a . is missing so its not a valide email address if instr returns a true the . is present so it
an valide email**** im not good at making tutorials anyway lets continue
Next Part is
ive combined both statments here this do just like the first and second part in the tutorial it looks if the first fromCode:ElseIf Right(mail, 1) = "." Then GoTo NotValide ElseIf Left(mail, 1) = "." Then GoTo NotValide
right or first from left is a . if yes its not a valide email address.
last part is
This is the error code in case @ is first symbol from left or right or . is first symbol from left or rightCode:NotValide: MsgBox "This is Not a Valide Email Address!" End If
Ok wow i never make a tutorial ok this funtion is just a basic one did it within 10 minutes but thought its
worth to post it Copyright of this Funtion NanoXcore thats me with dren,egzon,elban,limi![]()
Nice job. +rep
I forggot to tell how to use the funtion ok like u see we have an a declaration and also a request we declare
(mail As String) mail as string and also request it so to use it simply use this example
ValEmail(text1.text)
Very nice! +rep.
nice one bro .. and +rep indeed ..![]()
Great Job .. +rep![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks