Determining Letter or Number

lothos12345

Junior Contributor
Joined
May 2, 2002
Messages
294
Location
Texas
I have developed a Visual Basic.NET application that connects to a sql database. The application queries the database for data in a specific column/cell. This data can either be a fax number or and email address (keeping in mind that an e-mail address can be a mixture of both letters and numbers), is there a way that I can have the application tell the difference between e-mail and fax. So if the data pulled is a fax number it the application sends the information to our fax server, and if its an email address the application sends the information to our email server. The application needs to tell the difference. The fax number can be in any format from (210) 777-1234 to 210-777-1234 or 777-1234. The email address will always be in the following format "test123@test.com". A visual basic.net programming example of how to accomplish this would greatly be appreciated or any help for that matter.
 
here is something simple
Code:
     Dim str As String = strTheDataStringComapredOfFaxOrEmail
        Dim i As Integer = str.IndexOf("@")
        If i > 0 Then
            'do whatever for email
        else
            'do something for fax
        End If
 
Of course, you probably want to verify that either the e-mail of fax number is in a valid format. I would just check for and "@" followed by a "." and invalid characters for the e-mail and check that a phone number only contains digits (or letters if you want to allow them), parentheses, and dashes and spaces (and periods if you want to allow a format like "555.555.5555").
 
Back
Top