Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Snippet] Check Email if gmail and valid password length
#1
Check Email if gmail and valid password length.

Screenshot:
[Image: gmDAQ.png]

Code:
Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        checkemail(TextBox1.Text, TextBox2.Text)
    End Sub

    Private Shared Function checkemail(ByVal email As String, pass As String) As Boolean
        If isemailvalid(email) = True Then
            If isgmail(email) = True Then
                If validpass(pass) = True Then
                    MsgBox("Valid gmail and valid password Length!")
                    ' Do valid processing here!

                Else
                    MsgBox("Invalid Password Length!")
                End If
            Else
                MsgBox("Not a valid gmail account")
            End If
        Else
            MsgBox("Invalid Email")
        End If
    End Function

    Private Shared Function isemailvalid(ByVal email As String) As Boolean
        ' If the email matches the regular expression
        Dim Expression As New System.Text.RegularExpressions.Regex("\S+@\S+\.\S+")
        If Expression.IsMatch(email) Then
            Return True
        Else
            Return False
        End If
    End Function

    Private Shared Function isgmail(ByVal email As String) As Boolean
        If email.Contains("@gmail.com") = True Then
            Return True
        Else
            Return False
        End If
    End Function

    Private Shared Function validpass(ByVal pass As String) As Boolean
        If pass.Length >= 8 Then
            Return True
        Else
            Return False
        End If
    End Function
End Class

This code might be useful for validating email address, and for simple email sender/bomber.
USB Anti-virus? Try USB Drive Defender
[Image: 8bQCusS.jpg]
Reply
#2
It is actually good for those who want to know how to check if a string contains something.... o.O
This is really useful snippet for n00bs, good work.
Though, some people still use @googlemail.com.
Reply
#3
I am sure some people will find this useful thanks.
Reply
#4
Functions merge into one.

Code:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If checkemail(TextBox1.Text, TextBox2.Text) = True Then
            MsgBox("Email is valid")
        Else
            MsgBox("Email is invalid")
        End If
    End Sub

    Private Shared Function checkemail(ByVal email As String, pass As String) As Boolean
        ' If the email matches the regular expression
        Dim Expression As New System.Text.RegularExpressions.Regex("\S+@\S+\.\S+")
        If Expression.IsMatch(email) Then
            If email.Contains("@gmail.com") = True Then
                If pass.Length >= 8 Then
                    Return True
                Else
                    Return False 'Invalid password
                End If
            Else
                Return False 'Not a Gmail
            End If
        Else
            Return False 'Invalid email
        End If
    End Function
USB Anti-virus? Try USB Drive Defender
[Image: 8bQCusS.jpg]
Reply
#5
(05-12-2011, 06:47 AM)Gaijin Wrote: It is actually good for those who want to know how to check if a string contains something.... o.O
This is really useful snippet for n00bs, good work.
Though, some people still use @googlemail.com.

Yeah I agree with you Smile , But I am not noobSmileWhistle
[Image: UTLN2.gif]
That's not my Sig . So don't flame me.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [SF Coders] Password Generator ★Cooldude★ 23 11,844 03-19-2012, 06:40 PM
Last Post: AceInfinity
  [Snippet] Autoclose Msgbox euverve 7 3,280 05-25-2011, 06:41 PM
Last Post: Pyratepig
  [Snippet] Get Local Getway euverve 1 1,023 05-16-2011, 07:56 PM
Last Post: KoBE
  [Snippet] Get OS Uptime euverve 0 875 05-12-2011, 07:08 PM
Last Post: euverve
  [Source] My Gmail Email Sender euverve 1 848 05-12-2011, 08:30 AM
Last Post: begginer

Forum Jump:


Users browsing this thread: 2 Guest(s)