Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Check Email if gmail and valid password length

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.
1. If textbox1.text.contains("@gmail.com") then
Else
'email not gmail
End if

2. If textbox1.text.count < 4 then
' to short
Else
End if

is that it?

Well, that's it, but there is email validator.
(May 12, 2011 10:41 AM)Coleak Wrote:  1. If textbox1.text.contains("@gmail.com") then
Else
'email not gmail
End if

2. If textbox1.text.count < 4 then
' to short
Else
End if

is that it?

There's no need to use
If Something Then
Else
Do Work
Just Use If Not

If not textbox1.text.contains("@gmail.com") then
'email not gmail
End if
I merge it to one function.

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


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by sainthacker10over10Aug 13, 2020 06:20 PM 2 103 Aug 13, 2020 06:20 PM
Last Post: Political
[C] by SIM-2362662Apr 23, 2020 07:06 PM 11 375 Apr 23, 2020 07:06 PM
Last Post: dracx
[Python] by gurlhackerclubJan 29, 2020 02:48 AM 2 133 Jan 29, 2020 02:48 AM
Last Post: gurlhackerclub