Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validating email addresses

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I am working with a script that I found in a book I bought called ASP.NET: Tips, Tutorials, and Code. The script I am working with is on page 90 of that book. The purpose of the script is to make sure a email address has a valid domain. I believe I have no spelling errors and I recieve an error. Here is my code followed by the error.

Sub btnButton_submit( s As Object, e As EventArgs )

Dim strEmail as String, strPattern as String

strEmail = emailaddress.text
strPattern = "^[\w-_\.]+\@([\w]+\.)+\w+$"

If Not Regex.IsMatch(strEmail, strPattern, RegexOptions.IgnoreCase) Then
errortext.text = "Your Email Address is in the wrong format"
Else
Dim strDomain as String
strDomain = strEmail.Substring(strEmail.IndexOf("@") + 1)

Dim strIP as String
Try
strIP = DNS.Resolve(strDomain).AddressList(0)ToString() ' error is on this line
errortext.text = "Email Domain is correct"
Catch
errortext.text = "Email Domain is incorrect"
End Try
End if
End Sub

Compiler Error Message: BC30311: Value of type 'System.Net.IPAddress' cannot be converted to 'String'.

Source Error:



Line 22: Dim strIP as String
Line 23: Try
Line 24: strIP = DNS.Resolve(strDomain).AddressList(0)ToString()
Line 25: errortext.text = "Email Domain is correct"
Line 26: Catch


 
Line 24 should have a period before the ToString() part (unless thats just a typo in your post)

So
strIP = DNS.Resolve(strDomain).AddressList(0).ToString()

Jack
 
looks like a type to the book to me, maybe just my copy, but there was no period
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top