Results 1 to 5 of 5

Thread: ip

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    21

    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!

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: ip

    VB Code:
    1. Dim iPos As Long
    2.         iPos = InStr(strURL, "<TITLE>") + 7 '+7 to delete the <TITLE> part
    3.         MsgBox Mid(strURL, iPos)

    BTW, could you wrap your code in ['VBCODE'] ['/VBCODE']

    without the '

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    21

    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

  4. #4
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: ip

    Try this:

    VB Code:
    1. Private Sub Command1_Click()
    2. On Error GoTo Command1_Click_Error
    3.  
    4. Dim a As Integer, b As Integer
    5. Dim strURL As String
    6. Dim strIP As String
    7. Dim strSearchPrefix As String
    8. Dim strSearchSuffix As String
    9.  
    10. strSearchPrefix = "<TITLE>Your IP  Is "
    11. strSearchSuffix = " WhatIsMyIP.com</"
    12.  
    13. 'we open the [url]www.whatismyip.com[/url] URL and read it whole into strURL, this can take some time
    14. strURL = Inet1.OpenURL("http://www.whatismyip.com/")
    15. 'we find where the part before the IP is written
    16.  
    17. TryAgain:
    18. a = InStr(1, strURL, strSearchPrefix)
    19. 'we find the part after the IP
    20.  
    21. b = InStr(a, strURL, strSearchSuffix)
    22.  
    23. ' NOTE: the strURL doesnt have the actual Text you see in the browser in it, it has the HTML
    24. 'code of the site in it! You need to watch out for that
    25.  
    26. 'And the IP itself is between these two!
    27. ''strIP = Mid(strURL, a + 18, b - (a + 18))
    28. strIP = Trim(Mid(strURL, a + Len(strSearchPrefix), (b - a) - Len(strSearchSuffix) - 1))
    29. 'We let the user know what his IP is in form of message box
    30. Text3.Text = strIP
    31.  
    32. 'if user clicked Yes and he wants to copy the IP into the clipboard
    33. 'If temp = 6 Then
    34. ''first clear the clipboard
    35. 'Clipboard.Clear
    36. ''then assign new clipboard text - (our IP)
    37. 'Clipboard.SetText strIP
    38. 'End If
    39.  
    40. Text2.Text = Winsock1.LocalIP
    41. Text1.Text = Winsock1.LocalHostName
    42.  
    43. On Error GoTo 0
    44. Exit Sub
    45.  
    46. Command1_Click_Error:
    47. If Err.Number = 5 Then
    48.     strSearchPrefix = "<TITLE>Your IP  - "
    49.     GoTo TryAgain
    50. Else
    51.     MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Command1_Click of Form Form1"
    52. End If
    53. 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."


  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    21

    Re: ip

    Thank You Thank You, U R The Best Ever Thank You Lol..



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width