|
|
|

|

|
Dicas
|

|
Visual Basic.Net (Validações)
|
|
 |
Título da Dica: Validando E-mail no VB.net
|
 |
|
|
Postada em 27/1/2004 por messohal
Function IsEmail(ByVal Email) As Boolean Dim ValidFlag As Boolean = False Dim atCount As Integer Dim SpecialFlag As Boolean Dim atLoop As Integer Dim atChr As String Dim BadFlag As Boolean Dim tAry1(1) As String Dim UserNAme As String Dim domainName As String If (Email <> "") And (InStr(1, Email, "@") > 0) And (InStr(1, Email, ".") > 0) Then atCount = 0 SpecialFlag = False For atLoop = 1 To Len(Email) atChr = Mid(Email, atLoop, 1) If atChr = "@" Then atCount = atCount + 1 If (atChr >= Chr(32)) And (atChr <= Chr(44)) Then SpecialFlag = True If (atChr = Chr(47)) Or (atChr = Chr(96)) Or (atChr >= Chr(123)) Then SpecialFlag = True If (atChr >= Chr(58)) And (atChr <= Chr(63)) Then SpecialFlag = True If (atChr >= Chr(91)) And (atChr <= Chr(94)) Then SpecialFlag = True Next If (atCount = 1) And (SpecialFlag = False) Then BadFlag = False tAry1 = Split(Email, "@") UserNAme = tAry1(0) domainName = tAry1(1) If (UserNAme = "") Or (domainName = "") Then BadFlag = True If Mid(domainName, 1, 1) = "." Then BadFlag = True If Mid(domainName, Len(domainName), 1) = "." Then BadFlag = True ValidFlag = True End If End If If BadFlag = True Then ValidFlag = False IsEmail = ValidFlag End Function
Abraços
Emerson Silva .net Developer
|
|
|
|

|