IP address

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • radom
    New Member
    • Feb 2008
    • 37

    #1

    IP address

    How do I make vb2008 find my ip address
  • VBWheaties
    New Member
    • Feb 2008
    • 145

    #2
    Originally posted by radom
    How do I make vb2008 find my ip address
    Get the hostname then pass the hostname to GetHostByName which provides an AddressList collection. From this collection, you reference the 0 index which is the first IP address representing your PC.

    Example culled from search results:
    Code:
    Private Sub GetIPAddress()
    Dim strHostName As String
    Dim strIPAddress As String
    
    strHostName = System.Net.Dns.GetHostName()
    strIPAddress = System.Net.Dns.GetHostByName(strHostName).AddressList(0).ToString()
    
    MessageBox.Show("Host Name: " & strHostName & "; IP Address: " & strIPAddress)
    End Sub
    Last edited by VBWheaties; Feb 25 '08, 04:59 PM. Reason: added explanation of the code

    Comment

    • radom
      New Member
      • Feb 2008
      • 37

      #3
      Is this for vb 2008?

      Comment

      • radom
        New Member
        • Feb 2008
        • 37

        #4
        I got it to work but i get a bunch of gerberish

        Comment

        • VBWheaties
          New Member
          • Feb 2008
          • 145

          #5
          Originally posted by radom
          I got it to work but i get a bunch of gerberish
          please post the gerberish if you like.
          i think you might have new ipv6 addresses which are hexidecimal format.

          Comment

          Working...