VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 307,002 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,965 people online right now. Registration is fast and FREE... Join Now!




Email Identifier

 

Email Identifier, To see whether the email inputted is correct.

davidkimura

4 Nov, 2009 - 10:50 PM
Post #1

New D.I.C Head
*

Joined: 7 Oct, 2009
Posts: 2

Hi Peep,s
I working on this project and having trouble finishing it.
I have go some stuff done but need the help
it is number 3 on assissgnment 5

CODE

Public Class fmTitle

    Private Sub btnValidate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnValidate.Click

        'Declaring the Variables'
        Dim Email As String
        Dim AtSymbol As Integer
        Dim User As String
        Dim Domain As String

        Email = txtEnterEmail.Text.Trim

        If Email.Contains(" ") Then
            MessageBox.Show("Email address can't have spaces", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            txtEnterEmail.Focus()
            Return
        ElseIf Email.Contains("..") Then
            MessageBox.Show("Email address can't have consecutive periods", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            txtEnterEmail.Focus()
            Return
        ElseIf Not Email.Contains("@") Then
            MessageBox.Show("Email address must have one '@' symbol", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            txtEnterEmail.Focus()
            Return
        End If

        AtSymbol = Email.IndexOf("@")

        If Email.Contains("@") Then
            User = Email.Substring(0, AtSymbol)
            Domain = Email.Substring(AtSymbol + 1)
        Elseif
            User = ""
            Domain = ""
        ElseIf Domain.Contains("@") Then
            MessageBox.Show("Email address can't have more than one '@' symbol", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            txtEnterEmail.Focus()
            Return
        End If

    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

        'Closing the program
        Me.Close()

    End Sub
End Class


Mod Edit:
Fixed broken code tags. Be sure to include both tags like below.
code.gif


Attached File(s)
Attached File  Comp060_assignment5_c.doc ( 47.5k ) Number of downloads: 10

User is offlineProfile CardPM
+Quote Post


SixOfEleven

RE: Email Identifier

5 Nov, 2009 - 07:18 AM
Post #2

Code Guru
Group Icon

Joined: 18 Oct, 2008
Posts: 3,060



Thanked: 169 times
Dream Kudos: 775
Expert In: C, C#, XNA, Game Programming, Programming Concepts

My Contributions
Off to VB.NET.
User is offlineProfile CardPM
+Quote Post

motcom

RE: Email Identifier

6 Nov, 2009 - 12:55 AM
Post #3

D.I.C Addict
Group Icon

Joined: 16 Jun, 2008
Posts: 548



Thanked: 93 times
Dream Kudos: 175
My Contributions
Hi,

here is what i use

CODE

If System.Text.RegularExpressions.Regex.IsMatch(txtEmail.Text, "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$") = False Then
                'email address is not valid
            Else
                'email address is valid

            End If

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 06:26AM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month