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!
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
Re: Getting a Users External IP Address
Thread closed as it goes against the external website's terms of service.