Results 1 to 3 of 3

Thread: Getting a Users External IP Address

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2015
    Posts
    39

    Thumbs up Getting a Users External IP Address

    It was a pain in the butt to get the users external IP alone and return it to the user, so I made this:
    Code:
    Imports System.Net
    Imports System.Text.RegularExpressions
    
    Public Class Form1
    
        Dim ip As String = ""
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim web As New WebClient
            Dim fullstringip As String = web.DownloadString("http://whatismyipaddress.com/")
            Dim ipRegex As New System.Text.RegularExpressions.Regex("<a href=""//whatismyipaddress.com/ip/.*"" style=""")
            Dim matches As MatchCollection = ipRegex.Matches(fullstringip)
            For Each matchfound In matches
                Dim dirtyip As String = matchfound.ToString.Replace("<a href=""//whatismyipaddress.com/ip/", "")
                ip = dirtyip.Replace(""" style=""", "")
            Next
            MsgBox(ip) '<This is the final code with a messagebox to show the users IP.
        End Sub
    End Class
    It's easy and it works.
    Enjoy!

  2. #2
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Getting a Users External IP Address

    Thats not a very element piece of code. Have you got permission from the site?

    http://whatismyipaddress.com/api
    My Github - 1d3nt

  3. #3
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,370

    Re: Getting a Users External IP Address

    Thread closed as it goes against the external website's terms of service.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width