Click here to Skip to main content
15,882,017 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Where is my mistake?

VB
Imports System.Net
Imports System.IO
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Internal
        Try
            Dim h As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)
            Dim strLocalIp As String = h.AddressList.GetValue(0).ToString
            TextBox1.Text = strLocalIp
        Catch EX As Exception
        End Try

        'External
        Dim web As New System.Net.WebClient
        Dim myIP As String
        myIP = System.Text.Encoding.ASCII.GetString(( _
        web.DownloadData("http://whatismyip.com/automation/faq/n09230945.asp")))
        TextBox2.Text = myIP
    End Sub

End Class
Posted
Updated 14-Feb-12 19:02pm
v2
Comments
Sergey Alexandrovich Kryukov 14-Feb-12 23:02pm    
Not clear. What is it supposed to do? What's the problem?
--SA
Herman<T>.Instance 15-Feb-12 1:19am    
something tells me you found it here: http://www.youtube.com/watch?v=Stp877h_W7I
Bernhard Hiller 15-Feb-12 4:27am    
That service is quite interesting. When I wanted to know my IP address, I used to ping my dyndns.org address - and that would not be useful when trying to get the IP address of a different computer where my program is running...
Thanks to you for your question, and to digimanus for his solution.

1 solution

the same problem and solution here[^]
 
Share this answer
 
Comments
blueye89 15-Feb-12 8:00am    
I trying with your solution but I get a message:
"File moved-http://www.whatismyip.com/faq/automation.asp"
If I change web address to this I get a problem with WebResponse.
Why??
blueye89 15-Feb-12 8:08am    
I resolve it,I just putt this address in web client address:
http://whatismyip.org/
and it works.
Thanks everyone who tried to help me,I am coming back with new questions :-).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900