VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Email Validaton

by RajeswaraRao Gangina (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 10th April 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Email Validaton

Rate Email Validaton



Dim iTemp As Integer
    Select Case KeyAscii
        Case 8    'ASCII value of Back Space =8
                    ' Back space is allowed at any time
            Exit Sub
        Case Asc("@")   ' @ is allowed only if there are some characters in the textbox
            If TextBox.SelStart = 0 Then
                KeyAscii = 0
            ElseIf InStr(1, TextBox, "@") > 0 Then
                KeyAscii = 0
            End If
            Exit Sub
        Case Asc(".") ' . is allowed only after printing @
            iTemp = InStr(1, TextBox, "@")
            If (iTemp = 0) Or (iTemp >= TextBox.SelStart) Then
                KeyAscii = 0
                Exit Sub
            ElseIf TextBox.SelStart = 0 Then
                KeyAscii = 0
                Exit Sub
            ElseIf Mid(TextBox, TextBox.SelStart, 1) = "." Then
                KeyAscii = 0
                Exit Sub
            End If
            Exit Sub
        Case Asc("_") ' _ is allowed only before printing @
            iTemp = InStr(1, TextBox, "@")
            If (iTemp > 0) And (iTemp < TextBox.SelStart) Then
                KeyAscii = 0
            End If
            Exit Sub
    End Select
    If Not ((KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Or (KeyAscii >= Asc("a") And KeyAscii <= Asc("z")) Or (KeyAscii >= Asc("A") And KeyAscii <= Asc("Z"))) Then
        KeyAscii = 0
        Exit Sub
    End If

Download this snippet    Add to My Saved Code

Email Validaton Comments

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

Post your comment

Subject:
Message:
0/1000 characters