Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27159

VS 2010 How to get Wan?

$
0
0
Hello again,

I'm attempting to get my computers public IP (WAN) and I've used numerous codes suggested from the net and none of them seem to work!

Example #1:
Code:

  Function GetIpAddress() As String
        Dim ip As New WebClient
        Return ip.DownloadString("http://automation.whatismyip.com/n09230945.asp")
    End Function

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
              Me.GetIpAddress().ToString()
        MessageBox.Show(GetIpAddress())
    End Sub

Example #2:
Code:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim WC As New System.Net.WebClient
        Label2.Text =
        System.Text.Encoding.ASCII.GetString((WC.DownloadData("http://whatismyip.com/automation/n09230945.asp")))
        WC.Dispose()
        End Sub

Example #3:
Code:

'Dim ip() As Net.IPAddress = System.Net.Dns.GetHostAddresses("http://***ismyip.com/text")
    '
    'If ip.Count > 0 Then
    'For Each ipadd As Net.IPAddress In ip
    'Console.WriteLine(ipadd.ToString)
    'Next
    'End If

Example #4
Code:

'Dim req As HttpWebRequest = WebRequest.Create("http://***ismyip.com/text")
    'Dim res As HttpWebResponse = req.GetResponse()
    'Dim Stream As Stream = res.GetResponseStream()
    'Dim sr As StreamReader = New StreamReader(Stream)
    '  MessageBox.Show(sr.ReadToEnd())

When I press Button #3, nothing happens. Nothing. And I tested button 3 with other code to make sure that wasn't the issue and it isn't. If the code(s) should be working, then perhaps it's a router/firewall issue? Any help very much appreciated.

Viewing all articles
Browse latest Browse all 27159

Trending Articles