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

Related posts:

  1. How to get the remote computer name from IP address and How to get the remote system IP address from computer name
  2. How to Check an Email Address for Validity (VB.NET and VB6)
  3. How to get folder size of a given folder (in two ways)
  4. How to round off to the nearest 10 but not least, for example a) 10 would stay as 10 b) 11 would be 20 c) 3 would be 10 d) 22 would be 30 (in two ways)
  5. How to display animated Gif in your program
  6. How to Get Machine IP Address
  7. How to convert HTML code to Txt
  8. How to Kills Html Tags
  9. How to Get file extension for a given file (in two ways)
  10. How to get file size of a given file (in three ways)

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.