VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get IP Location Info

by Kreshnik (1 Submission)
Category: Internet/HTML
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

With this simple function your able to return information about an ip address. :D

Rate Get IP Location Info

Attribute VB_Name = "mLocIP"
'---------------------------------------------------------------------------------------
' Module   : mLocIP
' DateTime  : 19/12/2009 08:55PM
' Author   : Kresha7
' Mail    : [email protected]
' Purpose   : Gets Information about the location of an IP address
'---------------------------------------------------------------------------------------
Public Function LocateIP(IPAddr As String) As String
  Dim HTTP  As Object
  Dim StrRes As String
  Dim IP   As String, Region As String, Country As String, City As String, Latitude As String, Longitude As String, TZone As String, ISP As String, ConT As String
  Const URL = "http://www.ip2location.com/"
  Set HTTP = CreateObject("Winhttp.Winhttprequest.5.1")
  
  With HTTP
    .Open "POST", URL & IPAddr
    .Send
    StrRes = .ResponseText
    
  End With
  IP = Mid(Split(Split(StrRes, "dgLookup__ctl2_lblICountry")(1), "")(0), 3)
  Region = Mid(Split(Split(StrRes, "dgLookup__ctl2_lblIRegion")(1), "")(0), 3)
  Country = Mid(Split(Split(StrRes, "dgLookup__ctl2_lblICity")(1), "")(0), 3)
  Latitude = Mid(Split(Split(StrRes, "dgLookup__ctl2_lblILatitude")(1), "")(0), 3)
  Longitude = Mid(Split(Split(StrRes, "dgLookup__ctl2_lblILongitude")(1), "")(0), 3)
  TZone = Mid(Split(Split(StrRes, "dgLookup__ctl2_lblITimeZone")(1), "")(0), 3)
  ConT = Mid(Split(Split(StrRes, "dgLookup__ctl2_lblINetSpeed")(1), "")(0), 3)
  ISP = Mid(Split(Split(StrRes, "dgLookup__ctl2_lblIISP")(1), "")(0), 3)
LocateIP = IP & vbNewLine & Region & vbNewLine & Country & vbNewLine & Latitude & vbNewLine & Longitude & vbNewLine & TZone & vbNewLine & ConT & vbNewLine & ISP
End Function

Download this snippet    Add to My Saved Code

Get IP Location Info Comments

No comments have been posted about Get IP Location Info. Why not be the first to post a comment about Get IP Location Info.

Post your comment

Subject:
Message:
0/1000 characters