Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

Whats My IP Address ?

, 13 Sep 2011
Rate this:
Please Sign up or sign in to vote.
Different Method(s) to Find IP Address?
Method 1
 
Imports System.Net
 
'--------------------

Dim _HostName As String = Dns.GetHostName
 
MsgBox(_HostName)
 
'--------------------

Dim _IPHostEntry As IPHostEntry = Dns.GetHostByName(_HostName)
 
For Each _IP As IPAddress In _IPHostEntry.AddressList
   MsgBox(_IP.ToString)
Next
'--------------------
Method 2
 
Imports System.IO
Imports System.Text
'--------------------

MsgBox(GetInternetIPAddress())
'--------------------

Private Function GetInternetIPAddress() As String
Try
Dim _ObjReq As HttpWebRequest = WebRequest.Create("http://automation.whatismyip.com/n09230945.asp")
Dim _ObjRes As HttpWebResponse = _ObjReq.GetResponse()
Dim _ObjStream As Stream = _ObjRes.GetResponseStream()
Dim _ObjSR As StreamReader = New StreamReader(_ObjStream)
Return _ObjSR.ReadToEnd()
Catch ex As Exception
   Return String.Empty
End Try
End Function
 
'--------------------

License

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

Share

About the Author

Koshy Panicker John
Software Developer (Senior)
India India
No Biography provided

Comments and Discussions

 
QuestionThanks so much Pinmemberafpfdv5-Apr-13 17:59 
Generalhttp://automation.whatismyip.com/n09230945.asp doesn't work ... Pinmemberkiquenet AE21-Nov-11 20:30 
GeneralReason for my vote of 4 Thanks for the Code lines. PinmemberMember 432084427-Sep-11 8:24 
GeneralReason for my vote of 4 Thanks. PinmemberMember 432084427-Sep-11 8:15 
GeneralReason for my vote of 3 good one PinmemberHemant K Mahajan27-Sep-11 3:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140921.1 | Last Updated 13 Sep 2011
Article Copyright 2011 by Koshy Panicker John
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid