|
-
Dec 27th, 2005, 05:42 AM
#1
Thread Starter
Hyperactive Member
Get Internet IP Address.
Hi, I found this code on one of my computers and thought it might be usefull to someone. I did not write this code but i cannot remember who did. Please post if you are the writer of this code.
Put this code in a form
VB Code:
Function get_ip()
'Fetch external ip function
'- checks checkip.dyndns.org for computers ip adress
Dim ReturnedHTML As String, sIp As Long, sStop As Long
ReturnedHTML = ReturnHTML("http://checkip.dyndns.org/")
sIp = InStr(ReturnedHTML, "Address: ") + 9
If InStr(sIp, ReturnedHTML, ",") > 0 Then
sStop = InStr(sIp, ReturnedHTML, ",")
Else
sStop = InStr(sIp, ReturnedHTML, "<")
End If
If sStop > 0 Then 'Fetched ip
get_ip = Mid(ReturnedHTML, sIp, sStop - sIp)
Else 'Error occured
get_ip = "error"
End If
End Function
Private Function ReturnHTML(URL)
'Return HTML function
'- retrieves HTML for the given url
Dim objXMLHTTP, objRS, HTML
Set objXMLHTTP = CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "GET", URL, False
objXMLHTTP.Send
HTML = objXMLHTTP.responseBody
Set objRS = CreateObject("ADODB.Recordset")
objRS.Fields.Append "txt", 200, 45000, &H80
objRS.Open
objRS.AddNew
objRS.Fields("txt").AppendChunk HTML
ReturnHTML = objRS("txt").Value
objRS.Close
Set objXMLHTTP = Nothing
Set objRS = Nothing
End Function
The code can be used like this
VB Code:
me.caption = Get_IP
'or
text1.text = Get_IP
i did not write this code and i do not remember who wrote it.
If there is only one perfect person in the universe, does that make them imperfect?
-
Mar 28th, 2007, 08:31 PM
#2
New Member
Re: Get Internet IP Address.
-
Mar 30th, 2007, 02:06 PM
#3
Fanatic Member
Re: Get Internet IP Address.
Dandono, could you post the IP code again using 'code' tags.
The 'vbcode' tags will not allow to copy/paste....
Thanks
I want to add your code to the MAC code.
Alpha Micro: Alpha Basic, AS400 V5r2, EDI (Trusted Link/ Inovis.com),Access AS/400 via VB6, Qbasic for data conversions. A mix of Hardware too. ASCII Table , New Number to Words/66 digits , AS/400(v5r2) VB6 Viewer/Ask for code(ODBC) ^ What Is Transferring? , Check your Ports #Perfect Passwords , *Slide Bar Example , Logoff, Restart, Shut-Down PC *Keep Form On Top , Opaque Form ^ Create Objects at Run Time @ Check Key Caps Locks # GetTickCount(System Up Time) * Convert text to Excel & Collected Icons + Resize: Form/Text box ^ PC GateWay via Shell $ Drag & Drop Game ! PopUpMenu *Print File/no Open# Timer on Mult Forms ~ Splash & Mult Forms & Lots of Comments + Random/Timer/Guess * Dec >Hex >Oct >Bin % Get MAC (NIC) < saving to Registry > Wookiee Cookies \ BackUpDisk / World Conection SpeedTest $ Glossary Commonly Used Terms # phonetic list @ Detailed Computer Scan
When posting Code, Use tags.. [CODE] *Your Code* [/CODE]
-
Jul 1st, 2021, 07:36 AM
#4
Addicted Member
Re: Get Internet IP Address.
QUESTION:
This is a great code-bit. Seems to work flawlessly to get IP address of any connection.
I got this strange result from a remote customer. What does it mean if my parsed answer = "192.168.0.XXX", rather than the Publlic IP address?
Why or what conditions this method would give local machine ip address?
Last edited by Jimboat; Jul 23rd, 2021 at 08:22 AM.
/Jimboat
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|