Dim webname,weburl,filepath,language,errortext
' Check to see if the email format is correct
function IsValidEmail (email)
Dim names,name,i,c
Isvalidemail=true
' Use the @ character to divide the email string into substrings and save them in the names array
Names=split (email, "@")
The ' UBound function returns the largest subscript of the array names, UBound (names) <>1 indicates that the @ character exists in the email string
' Not a, so email is not a valid email address format
If UBound (names) <>1 then
Isvalidemail=false
Exit function
End If
For each element in the array names of each name in names '
Number of characters within the If Len (name) <=0 Then ' string name
Isvalidemail=false
Exit function
End If
For I=1 to Len (name)
' Mid ' returns the name,i,1 character in the string name, which is converted to lowercase by the LCase function
C=lcase (Mid (name,i,1))
The ' InStr function returns the position of the first occurrence of a string in another string.
' InStr ("abcdefghijklmnopqrstuvwxyz_-.", c) <=0 indicates that character C is not a string
' "abcdefghijklmnopqrstuvwxyz_-." , IsNumeric (c) determines whether the character C is a number
If InStr ("abcdefghijklmnopqrstuvwxyz_-.", c) <=0 and not IsNumeric (c) Then ' does not support Chinese format addresses
Isvalidemail=false
Exit function
End If
Next
' Left (name,1) returns the leftmost character of the string name. Right (name,1) returns the rightmost character of the string name
If left (name,1) = "." or Right (name,1) = "." Then
Isvalidemail=false
Exit function
End If
Next
If InStr (Names (1), ".") <=0 Then ' email string @ The right part of @ does not contain characters '.
Isvalidemail=false
Exit function
End If
The ' InStrRev function returns the position of a string that appears from the end in another string,
' InStrRev (names (1), ".") Get the character "." The position from the end of the string names (1)
I=len (names (1))-InStrRev (names (1), ".")
' E-mail is last generally CN or COM, with a length of 2 or 3
If I<>2 and i<>3 then
Isvalidemail=false
Exit function
End If
' There is a string in the email ' ... '
If InStr (email, "...") >0 Then
Isvalidemail=false
End If
End Function