>Dim value As String >Dim webClient As New System.Net.WebClient > >value = New System.Text.UTF8Encoding().GetString(webClient.DownloadData("http://whatismyip.org/")) >>
Public Shared Function GetExternalIP() As String Dim value As String Dim webClient As System.Net.WebClient Try 'Instantiate objects webClient = New System.Net.WebClient 'Add header to request webClient.Headers.Add(Net.HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)") 'Retrieves the value from whatismyip.org value = New System.Text.UTF8Encoding().GetString(webClient.DownloadData("http://whatismyip.org/")) Catch ex As Exception Throw New ApplicationException("Unable to load external IP address.") End Try Return value End Function