Jump to content
SkyRanger

[VB] Need help with email verify

Recommended Posts

Trying to figure out how to verify if email is an email.  txtEMAIL.Text

Imports System.Text.RegularExpressions

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        If txtFULLNAME.Text = "" Then
            Form6.Show()
            Form6.Label1.Text = "You must enter your Full Name"
        ElseIf txtEMAIL.Text = "" Then
            Form6.Show()
            Form6.Label1.Text = "You must enter your Email Address"
        Else
            Form5.Show()
            Form2.txtFULLNAME.Text = txtFULLNAME.Text
            Form3.txtFULLNAME.Text = txtFULLNAME.Text
            Form4.txtFULLNAME.Text = txtFULLNAME.Text
            Form5.txtFULLNAME.Text = txtFULLNAME.Text
            Form2.txtEMAIL.Text = txtEMAIL.Text
            Form3.txtEMAIL.Text = txtEMAIL.Text
            Form4.txtEMAIL.Text = txtEMAIL.Text
            Me.Hide()

        End If
    End Sub

Trying to figure out how to insert the Regex in to what is above to have it work properly

Dim par As String
par="^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"
If Regex.IsMatch(txtEMAIL.Text, par) Then
 'do nothing and continue'
Else
 Form6.Show()
 Form6.Label1.Text = "You must enter a proper Email Address"
End If

 

Share this post


Link to post
Share on other sites

After scratching my head and staring at it for a bit.  Figured it out.  Need to verify a proper email is entered before continuing.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim par As String
        par = "^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"
        If Regex.IsMatch(txtEMAIL.Text, par) Then
            If txtFULLNAME.Text = "" Then
                Form6.Show()
                Form6.Label1.Text = "You must enter your Full Name"
            ElseIf txtEMAIL.Text = "" Then
                Form6.Show()
                Form6.Label1.Text = "You must enter your Email Address"
            Else
                Form5.Show()
                Form2.txtFULLNAME.Text = txtFULLNAME.Text
                Form3.txtFULLNAME.Text = txtFULLNAME.Text
                Form4.txtFULLNAME.Text = txtFULLNAME.Text
                Form5.txtFULLNAME.Text = txtFULLNAME.Text
                Form2.txtEMAIL.Text = txtEMAIL.Text
                Form3.txtEMAIL.Text = txtEMAIL.Text
                Form4.txtEMAIL.Text = txtEMAIL.Text
                Me.Hide()

            End If
        Else
            Form6.Show()
            Form6.Label1.Text = "You must enter a proper Email Address"
        End If


    End Sub

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.