CodeItBetter Programming Another VB Programming Blog

How to get IP address from http://www.myipaddress.com/ (in two ways)

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'Internet - How to get IP address from http://www.myipaddress.com/ (in two ways)
'Create a new project with a command button and a webbrowser control

Option Explicit
 
Private Sub Command1_Click()
    Dim pos As Long
    Dim PageSource As String
    PageSource = WebBrowser1.Document.body.innerhtml
    pos = InStr(1, PageSource, "<B>") + 3    '+3 as that is the length of <B>
    Debug.Print Mid$(PageSource, pos, InStr(pos, PageSource, "<") - pos)
End Sub
 
Private Sub Form_Load()
    WebBrowser1.Navigate2 "http://www.myipaddress.com/"
End Sub
 
'Another way

Private Sub Form_Load()
'Add inet control to your form
    Debug.Print Inet1.OpenURL("http://www.whatismyip.org/", icString)
End Sub
Filed under: Internet Leave a comment
Comments (1) Trackbacks (0)
  1. Hi,

    Option 1 of the get ip address doesn’t appear to work. I get a Begin ALLWEBMENUS CODE string but no i/p address ?!?!


Leave a comment


 

No trackbacks yet.