Public Function GetPublicIP()
Dim sSourceUrl As String
Dim sLocalFile As String
Dim hfile As Long
Dim buff As String
Dim pos1 As Long
Dim pos2 As Long
sSourceUrl = “http://vbnet.mvps.org/resources/tools/getpublicip.shtml”
sLocalFile = “c:ip.txt”
Call DeleteUrlCacheEntry(sSourceUrl)
If DownloadFile(sSourceUrl, sLocalFile) Then
hfile = FreeFile
Open sLocalFile For Input As #hfile
buff = Input$(LOF(hfile), hfile)
Close #hfile
pos1 = InStr(buff, “var ip =”)
If pos1 Then
pos1 = InStr(pos1 + 1, buff, “‘”, vbTextCompare) + 1
pos2 = InStr(pos1 + 1, buff, “‘”, vbTextCompare) ‘- 1
GetPublicIP = Mid$(buff, pos1, pos2 – pos1)
Else
GetPublicIP = “Your Application can’t get you wan ip address”
End If
Kill sLocalFile
Else
GetPublicIP = “Your Application can’t get you wan ip address”
End If
End Function