VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Email ID Validation...

by Ameer Ali (1 Submission)
Category: Internet/HTML
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 5th June 2009
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Email ID Validation...

API Declarations



Public Function EXTisOK(sEXT As String) As Boolean

Dim EXT As String, X As Long

EXTisOK = False

If Left(sEXT, 1) <> "." Then sEXT = "." & sEXT
sEXT = UCase(sEXT) 'just to avoid errors
EXT = EXT & ".COM.EDU.GOV.NET.BIZ.ORG.TV"
EXT = EXT & ".AF.AL.DZ.As.AD.AO.AI.AQ.AG.AP.AR.AM.AW.AU.AT.AZ.BS.BH.BD.BB.BY"
EXT = EXT & ".BE.BZ.BJ.BM.BT.BO.BA.BW.BV.BR.IO.BN.BG.BF.MM.BI.KH.CM.CA.CV.KY"
EXT = EXT & ".CF.TD.CL.CN.CX.CC.CO.KM.CG.CD.CK.CR.CI.HR.CU.CY.CZ.DK.DJ.DM.DO"
EXT = EXT & ".TP.EC.EG.SV.GQ.ER.EE.ET.FK.FO.FJ.FI.CS.SU.FR.FX.GF.PF.TF.GA.GM.GE.DE"
EXT = EXT & ".GH.GI.GB.GR.GL.GD.GP.GU.GT.GN.GW.GY.HT.HM.HN.HK.HU.IS.IN.ID.IR.IQ"
EXT = EXT & ".IE.IL.IT.JM.JP.JO.KZ.KE.KI.KW.KG.LA.LV.LB.LS.LR.LY.LI.LT.LU.MO.MK.MG"
EXT = EXT & ".MW.MY.MV.ML.MT.MH.MQ.MR.MU.YT.MX.FM.MD.MC.MN.MS.MA.MZ.NA"
EXT = EXT & ".NR.NP.NL.AN.NT.NC.NZ.NI.NE.NG.NU.NF.KP.MP.NO.OM.PK.PW.PA.PG.PY"
EXT = EXT & ".PE.PH.PN.PL.PT.PR.QA.RE.RO.RU.RW.GS.SH.KN.LC.PM.ST.VC.SM.SA.SN.SC"
EXT = EXT & ".SL.SG.SK.SI.SB.SO.ZA.KR.ES.LK.SD.SR.SJ.SZ.SE.CH.SY.TJ.TW.TZ.TH.TG.TK"
EXT = EXT & ".TO.TT.TN.TR.TM.TC.TV.UG.UA.AE.UK.US.UY.UM.UZ.VU.VA.VE.VN.VG.VI"
EXT = EXT & ".WF.WS.EH.YE.YU.ZR.ZM.ZW"
EXT = UCase(EXT) 'just to avoid errors
If InStr(1, EXT, sEXT) <> 0 Then EXTisOK = True

End Function

Rate Email ID Validation...




Dim sEXT As String
Dim strTmp As String
Dim msg As Integer

If (Txt_Email <> "") Then
        
    msg = 0
    
    sEXT = Txt_Email
    
    Do While InStr(1, sEXT, ".") <> 0
        sEXT = Right(sEXT, Len(sEXT) - InStr(1, sEXT, "."))
    Loop
    
    If InStr(1, Txt_Email, "@") = 0 Then
    
        MsgBox "Email Id does not contain an @ sign.", vbInformation
        Txt_Email.SetFocus
        msg = 1
    ElseIf InStr(1, Txt_Email, "@") = 1 Then
    
        MsgBox "@ Sign can not be the first character in Email Id!"
        Txt_Email.SetFocus
        msg = 1
    ElseIf InStr(1, Txt_Email, "@") = Len(Txt_Email) Then
    
        MsgBox "@Sign can not be the last character in Email Id!"
        Txt_Email.SetFocus
        msg = 1
    ElseIf InStr(Len(Txt_Email), Txt_Email, ".") = Len(Txt_Email) Then
    
        MsgBox " '.' Sign can not be the last character in Email Id!"
        Txt_Email.SetFocus
        msg = 1
    ElseIf Len(sEXT) < 2 Then
    
       MsgBox "Email Id is not carrying a valid ending!"
        Txt_Email.SetFocus
        msg = 1
    ElseIf EXTisOK(sEXT) = False Then
        MsgBox "Email Id is not carrying a valid ending!"
        Txt_Email.SetFocus
        msg = 1
    
    ElseIf Len(Txt_Email) < 6 Then
    
        MsgBox "Email Id is shorter than 6 characters which is Impossible."
        Txt_Email.SetFocus
        msg = 1
    ElseIf InStr(1, Txt_Email, "@") <> 0 Then
    
        n = 0
        strTmp = Txt_Email
        
        Do While InStr(1, strTmp, "@") <> 0
            n = n + 1
            strTmp = Right(strTmp, Len(strTmp) - InStr(1, strTmp, "@"))
            If n = 2 Then
                MsgBox "More than 1 @ sign in your Email Id"
                Txt_Email.SetFocus
                msg = 1
                Exit Do
            End If
        Loop
    End If
    
    If msg = 0 Then
        ' nextcontrol.SetFocus
    End If
End If
End Sub

Download this snippet    Add to My Saved Code

Email ID Validation... Comments

No comments have been posted about Email ID Validation.... Why not be the first to post a comment about Email ID Validation....

Post your comment

Subject:
Message:
0/1000 characters