|
Thread: ip
-
Dec 3rd, 2005, 11:54 AM
#1
Thread Starter
Junior Member
ip
Hey,
i have this script..
Private Sub Form_Load()
Dim a As Integer, b As Integer
Dim strURL As String, strIP As String
'we open the www.whatismyip.com URL and read it whole into strURL, this can take some time
strURL = Inet1.OpenURL("http://www.whatismyip.com/")
'we find where the part before the IP is written
a = InStr(1, strURL, "<TITLE>Your ip is ")
'we find the part after the IP
b = InStr(1, strURL, " WhatIsMyIP.com</TITLE>")
' NOTE: the strURL doesnt have the actual Text you see in the browser in it, it has the HTML
'code of the site in it! You need to watch out for that
'And the IP itself is between these two!
strIP = Mid(strURL, a + 18, b - (a + 18))
'We let the user know what his IP is in form of message box
Text3.Text = strIP
'if user clicked Yes and he wants to copy the IP into the clipboard
If temp = 6 Then
'first clear the clipboard
Clipboard.Clear
'then assign new clipboard text - (our IP)
Clipboard.SetText strIP
End If
Text2.Text = Winsock1.LocalIP
Text1.Text = Winsock1.LocalHostName
End Sub
Private Sub Image2_Click()
On Error Resume Next
Me.WindowState = 0
Do
Me.Top = Me.Top + 10
Me.Left = Me.Left + 10
Me.Width = Me.Width - 20
Me.Height = Me.Height - 20
Loop Until Me.Top >= Screen.Height
'you can change those numbers to make it
' faster
'or slower. right now it is pretty slow.
'
'if the height and width #'s are twice a
' s much
'as the top and left #'s, it will make a
'
' "zooming out" effect and then will fal
' l to the
'bottom of the screen.
Unload Me
End Sub
ok it all works fine, but now when i preview it, instead of it just telling me my ip, it just says this
BLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Your IP Is (79.105.687.228)
....so can anyone help me get everything from the BLIC part allthe way to the <Title> part off?? please that would be sweet if you all could help me and show me how. Thanks so much guyz!
-
Dec 3rd, 2005, 01:33 PM
#2
Re: ip
VB Code:
Dim iPos As Long
iPos = InStr(strURL, "<TITLE>") + 7 '+7 to delete the <TITLE> part
MsgBox Mid(strURL, iPos)
BTW, could you wrap your code in ['VBCODE'] ['/VBCODE']
without the '
-
Dec 3rd, 2005, 03:34 PM
#3
Thread Starter
Junior Member
Re: ip
hey,
I kinda don understand what ur sayin. Im kinda new at vb, so can you take my script and add what you put so it works, becasue i tried it and it gave me an error. Let me know, thanks again!
-Calvin
-
Dec 3rd, 2005, 05:22 PM
#4
Re: ip
Try this:
VB Code:
Private Sub Command1_Click()
On Error GoTo Command1_Click_Error
Dim a As Integer, b As Integer
Dim strURL As String
Dim strIP As String
Dim strSearchPrefix As String
Dim strSearchSuffix As String
strSearchPrefix = "<TITLE>Your IP Is "
strSearchSuffix = " WhatIsMyIP.com</"
'we open the [url]www.whatismyip.com[/url] URL and read it whole into strURL, this can take some time
strURL = Inet1.OpenURL("http://www.whatismyip.com/")
'we find where the part before the IP is written
TryAgain:
a = InStr(1, strURL, strSearchPrefix)
'we find the part after the IP
b = InStr(a, strURL, strSearchSuffix)
' NOTE: the strURL doesnt have the actual Text you see in the browser in it, it has the HTML
'code of the site in it! You need to watch out for that
'And the IP itself is between these two!
''strIP = Mid(strURL, a + 18, b - (a + 18))
strIP = Trim(Mid(strURL, a + Len(strSearchPrefix), (b - a) - Len(strSearchSuffix) - 1))
'We let the user know what his IP is in form of message box
Text3.Text = strIP
'if user clicked Yes and he wants to copy the IP into the clipboard
'If temp = 6 Then
''first clear the clipboard
'Clipboard.Clear
''then assign new clipboard text - (our IP)
'Clipboard.SetText strIP
'End If
Text2.Text = Winsock1.LocalIP
Text1.Text = Winsock1.LocalHostName
On Error GoTo 0
Exit Sub
Command1_Click_Error:
If Err.Number = 5 Then
strSearchPrefix = "<TITLE>Your IP - "
GoTo TryAgain
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Command1_Click of Form Form1"
End If
End Sub
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Dec 3rd, 2005, 07:56 PM
#5
Thread Starter
Junior Member
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
|