Judging whether the string is legal email

zhaozj2021-02-16  57

Public Function IsValidemail (stremail as string) AS Boolean Dim Names, Name, I, C IsValidemail = true names = split (stremail, "@")

IF Ubound (Names) <> 1 Then IsValidemail = false exit function endiff

For Each Name in Names

IF len (name) <= 0 dam isvalidemail = false exit function endiff

For i = 1 to len (name) c = lcase (MID (Name, I, 1))

IF INSTR ("AbcdefghijklmnopqrStuvwxyz_-.", C) <= 0 and not isnumeric (c) Then isvalidemail = false exit function end if next

IF LEFT (Name, 1) = "." Or right (name, 1) = "." "The isvalidemail = false exit function endiff

NEXT

IF INSTR (Names (1), ".") <= 0 Then IsValidemail = false exit function endiff

I = LEN (Names (1)) - Instrrev (Names (1), ".")

IF i <> 2 and i <> 3 Then isvalidemail = false exit function endiff

If ISTR (Stremail, "..")> 0 damsValidemail = false exit function endiff

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-24791.html

New Post(0)