Ok i know that you can you much easier ways in dotnet to get your public ip but this is how I’ve done it.It’s in vb.net

Option Explicit On
Imports System.Text
Imports System.Net
Imports System.IO
Public Function WhatsMyIP() As String
WhatsMyIP = Nothing
Const TheURL = “http://www.whatismyip.com/automation/n09230945.asp”
Dim Request As HttpWebRequest = WebRequest.Create(TheURL)
Dim Response As HttpWebResponse = Request.GetResponse

Dim Encode As Encoding = Encoding.GetEncoding(1252)

Dim Stream As New StreamReader(Response.GetResponseStream(), Encode)
Dim ResString As String = Stream.ReadToEnd()

WhatsMyIP = ResString

Catch Ex As Exception
End Try

End Function


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s