一个简单的E_mail地址判断函数

  Author:I94Self |

  ' | E_mail:I94Self@hotmail.com |

  ' | HTTP://www.I94Self.com |

  ' | Please save author information |

  ' —————————————————

  ''''''''''''''''''''''''''''''''

  ' 判断E_mail输入是否正确 '

  ''''''''''''''''''''''''''''''''

  Function IsValidE_mail(E_mail)

  '判断E_mail地址中是否有@符号,如果没有@符号或者@符号在E_mail字符第一个或最后一个,则函数都返回False,并退出函数。

  E_mailArray=Split(E_mail, "@")

  If UBound(E_mailArray)<>1 Then

  IsValidE_mail=False

  Exit Function

  End If

  '判断E_mail地址中是否有连在一起的..符号(包括了...或无数个.连接的符号),如果有,则函数都返回False,并退出函数。

  If InStr(E_mail,"..")>0 Then

  IsValidE_mail=False

  Exit Function

  End If

  '判断E_mail地址中@后的字符串是否有.字符,如果没有.符号或者.符号在E_mail字符第一个,则函数都返回False,并退出函数。

  If InStr(E_mailArray(1), ".") <= 0 Then

  IsValidE_mail = False

  Exit Function

  End If

  '判断E_mail地址中.后的字符串是否等于2字符或3字符,如果不等于,则函数都返回False,并退出函数。

  Number=Len(E_mailArray(1))-InStrRev(E_mailArray(1),".")

  If Number<>2 And Number<>3 Then

  IsValidE_mail=False

  Exit Function

  #code.google.com/p/bjbk;

  #code.google.com/p/bjck;

  #code.google.com/p/bjmk;

  #code.google.com/p/bjbz;

  #code.google.com/p/bjcs;

  #code.google.com/p/shdb;

  #code.google.com/p/shcs;

  #code.google.com/p/shda;

  #code.google.com/p/shdai;

  #code.google.com/p/shcsh;

  #code.google.com/p/tjmc;

  #code.google.com/p/tjms;

  #code.google.com/p/tjys;

  #code.google.com/p/tjma;

  #code.google.com/p/tjmsd;

  #code.google.com/p/cqms;

  #code.google.com/p/cqma;

  #code.google.com/p/cqmd;

  #code.google.com/p/cqmf;

  #code.google.com/p/cqmg;

  #code.google.com/p/hebma;

  #code.google.com/p/hebms;

  #code.google.com/p/hebmd;

  #code.google.com/p/hebmg;

  #code.google.com/p/hebmq;

  #code.google.com/p/jlma;

  #code.google.com/p/jlmd;

  #code.google.com/p/jlmf;

  #code.google.com/p/jlcsa;

  #code.google.com/p/jlcss;

  #code.google.com/p/ccmts;

  #code.google.com/p/ccmtd;

  #code.google.com/p/ccmtf;

  #code.google.com/p/ccmtg;

  #code.google.com/p/ccmtw;

  #code.google.com/p/symts;

  #code.google.com/p/symtt;

  #code.google.com/p/symty;

  #code.google.com/p/symtz;

  #code.google.com/p/symtx;

  #code.google.com/p/dlmta;

  #code.google.com/p/dlcs;

  #code.google.com/p/dldba;

  #code.google.com/p/dldbs;

  #code.google.com/p/dlcsd;

  #code.google.com/p/asmtw;

  #code.google.com/p/asmte;

  #code.google.com/p/asmtr;

  #code.google.com/p/jnmtw;

  #code.google.com/p/jnmte;

  #code.google.com/p/jnmtr;

  #code.google.com/p/jnmtt;

  #code.google.com/p/jnmta;

  #code.google.com/p/jnmts;

  #code.google.com/p/qdmt;

  #code.google.com/p/qdmtq;

  #code.google.com/p/qdmtw;

  #code.google.com/p/qdmte;

  #code.google.com/p/qdmtr;

  #code.google.com/p/qdmta;

  #code.google.com/p/zbmtq;

  #code.google.com/p/zbcs;

  #code.google.com/p/dymte;

  #code.google.com/p/dycs;

  #code.google.com/p/dycsa;

  #code.google.com/p/ytmtr;

  #code.google.com/p/ytdg;

  #code.google.com/p/ytcs;

  #code.google.com/p/wfcs;

  #code.google.com/p/wfmtq;

  #code.google.com/p/tymtq;

  #code.google.com/p/tymtw;

  #code.google.com/p/tycs;

  #code.google.com/p/tycsa;

  #code.google.com/p/tycss;

  #code.google.com/p/xamt;

  #code.google.com/p/sayh;

  #code.google.com/p/xadba;

  #code.google.com/p/xadbd;

  #code.google.com/p/xacsa;

  #code.google.com/p/sjzcs;

  #code.google.com/p/sjzcsa;

  #code.google.com/p/sjzdg;

  #code.google.com/p/sjzsb;

  #code.google.com/p/sjzdbs;

  #code.google.com/p/sjzbs;

  #code.google.com/p/tssb;

  #code.google.com/p/tsdba;

  #code.google.com/p/tscss;

  #code.google.com/p/qhdcs;

  #code.google.com/p/qhddb;

  #code.google.com/p/qhdcsa;

  #code.google.com/p/lysbd;

  #code.google.com/p/sycs;

  #code.google.com/p/sydb;

  #code.google.com/p/zzcs;

  #code.google.com/p/zzdba;

  #code.google.com/p/zzcsd;

  #code.google.com/p/zzdbs;

  #code.google.com/p/zzcsa;

  #code.google.com/p/whcs;

  #code.google.com/p/whcsa;

  #code.google.com/p/whdb;

  #code.google.com/p/whdba;

  #code.google.com/p/whcss;

  #code.google.com/p/cccsa;

  #code.google.com/p/cccsd;

  #code.google.com/p/csdba;

  #code.google.com/p/csdbs;

  #code.google.com/p/cscsa;

  #code.google.com/p/wxcsa;

  #code.google.com/p/wxcss;

  #code.google.com/p/wxcsd;

  #code.google.com/p/wxdb;

  #code.google.com/p/wxcsf;

  #code.google.com/p/njds;

  #code.google.com/p/njcs;

  #code.google.com/p/njcsa;

  #code.google.com/p/njcss;

  #code.google.com/p/njdb;

  #code.google.com/p/szcsa;

  #code.google.com/p/szcss;

  #code.google.com/p/szcsd;

  #code.google.com/p/szdb;

  #code.google.com/p/szcsf;

  #code.google.com/p/nbcs;

  #code.google.com/p/dbcsa;

  #code.google.com/p/nbdb;

  #code.google.com/p/nbdbs;

  #code.google.com/p/nbcsa;

  #code.google.com/p/hzdb;

  #code.google.com/p/hzdba;

  #code.google.com/p/hzdbs;

  #code.google.com/p/hzcs;

  #code.google.com/p/hzcss;

  #code.google.com/p/fzcs;

  #code.google.com/p/fzcsa;

  #code.google.com/p/fzdb;

  #code.google.com/p/fwdb;

  #code.google.com/p/fzcss;

  #code.google.com/p/xmcs;

  #code.google.com/p/xmdb;

  #code.google.com/p/xmdba;

  #code.google.com/p/xmdbs;

  #code.google.com/p/xmcsa;

  #code.google.com/p/kmcs;

  #code.google.com/p/kmcsd;

  #code.google.com/p/kmdb;

  #code.google.com/p/kmdba;

  #code.google.com/p/kmcsa;

  #code.google.com/p/cdcsa;

  #code.google.com/p/cscss;

  #code.google.com/p/cdcss;

  #code.google.com/p/cddb;

  #code.google.com/p/cdcsd;

  #code.google.com/p/hfcs;

  #code.google.com/p/hfcsa;

  #code.google.com/p/hfcss;

  #code.google.com/p/hfdb;

  #code.google.com/p/hfdba;

  #code.google.com/p/gycs;

  #code.google.com/p/gycsa;

  #code.google.com/p/gycss;

  #code.google.com/p/gydb;

  #code.google.com/p/gydba;

  #code.google.com/p/xzcs;

  #code.google.com/p/xzdbs;

  #code.google.com/p/xzdb;

  #code.google.com/p/ntcs;

  #code.google.com/p/ntcsa;

  #code.google.com/p/ntcss;

  #code.google.com/p/ntcsd;

  #code.google.com/p/jhcsa;

  #code.google.com/p/jhdb;

  #code.google.com/p/jhcss;

  #code.google.com/p/zjcs;

  #code.google.com/p/zjdba;

  #code.google.com/p/yzcsa;

  #code.google.com/p/yzcss;

  #code.google.com/p/yzdb;

  #code.google.com/p/yzdba;

  #code.google.com/p/nccs;

  #code.google.com/p/nccsa;

  #code.google.com/p/nccsd;

  #code.google.com/p/ncdba;

  #code.google.com/p/ncdbs;

  #code.google.com/p/gzcs;

  #code.google.com/p/gzdb;

  #code.google.com/p/gzcsa;

  #code.google.com/p/gzdba;

  #code.google.com/p/gzdbs;

  #code.google.com/p/szcsw;

  #code.google.com/p/szcse;

  #code.google.com/p/szdg;

  #code.google.com/p/szdbs;

  #code.google.com/p/szdbf;

  #code.google.com/p/zscs;

  #code.google.com/p/zsdb;

  #code.google.com/p/zsdba;

  #code.google.com/p/stcsa;

  #code.google.com/p/stcss;

  #code.google.com/p/stdba;

  #code.google.com/p/fscsa;

  #code.google.com/p/fsdb;

  #code.google.com/p/fwcsd;

  #code.google.com/p/wsdb;

  #code.google.com/p/lzcsa;

  #code.google.com/p/lzcss;

  #code.google.com/p/lzdba;

  #code.google.com/p/lzcsd;

  #code.google.com/p/lzcsf;

  #code.google.com/p/zhcs;

  #code.google.com/p/zhcsa;

  #code.google.com/p/zhdb;

  #code.google.com/p/hzcsf;

  #code.google.com/p/hzdbd;

  End If

  For Each E_mailArrayContent In E_mailArray

  '判断E_mail地址中@前是否有字符,如果没有,则函数都返回False,并退出函数。

  If Len(E_mailArrayContent)<=0 Then

  IsValidE_mail=False

  Exit Function

  End If

  '判断E_mail地址中是否含有除abcdefghijklmnopqrstuvwxyz_-和数字以外的非法字符,如果含有,则函数返回False,并退出函数。

  For Number=1 To Len(E_mailArrayContent)

  E_mailStr=Lcase(Mid(E_mailArrayContent,Number,1))

  If InStr("abcdefghijklmnopqrstuvwxyz_-.",E_mailStr)<=0 And Not IsNumeric(E_mailStr) Then

  IsValidE_mail=False

  Exit Function

  End If

  Next

  '判断E_mail地址中@前后的字符串中是否第一个和是最后一个字符是.字符,如果是,则函数都返回False,并退出函数。

  If Left(E_mailArrayContent,1)="." Or Right(E_mailArrayContent,1)="." Then

  IsValidE_mail=False

  Exit Function

  End If

  Next

  '没有发现E_mail地址中有异常字符,函数返回True,函数结束。

  IsValidE_mail=True

  End Function

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值