[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

WAN IP retrieve no longer working

Posted on 2006-04-11
2
Medium Priority
?
156 Views
Last Modified: 2010-05-03
Hi there,

it has been a long long time since I used this, and it always USED to work without fail.

do any of you guys know why it no longer works, I suspect it is becasue www.whatsmyip.com no longer has the same format as it used to. But I am not sure about how to put this right.

thanks guys

Private Sub Command1_Click()
Timer1.Enabled = False
    Form1.Caption = "Countdown stopped!"
End Sub

Private Sub Form_Load()
    Dim IE, RET, POS1, POS2
    Set IE = CreateObject("internetexplorer.application")
        IE.navigate "http://www.whatismyip.com"
        While IE.busy: DoEvents: Wend
        RET = IE.document.Title
        IE.Quit
    Set IE = Nothing
    POS1 = InStr(1, RET, "is", vbTextCompare) + 3
    POS2 = InStr(1, RET, "what", vbTextCompare)
    Open "c:\ipoutputfile.txt" For Output As #1
        Print #1, Mid(RET, POS1, POS2 = (POS1 + 1))
    Close #1
   
      On Error Resume Next                    'If error arises, goto next line
   
    fil = "c:\ipoutputfile.txt"                 'Select which file to look for
   
    Open fil For Input As #1                'Try to open the file
    Close #1
   
    If Err <> 0 Then                        'If the file soesn't exist, error will ocurr
        Open fil For Output As #1           'In case of error create the missing file
        Close #1
    Else
        Command1.Caption = "Stop the timer"
        Timer1.Tag = 5
        Timer1.Interval = 1000
        Timer1.Enabled = True               'If there's no error (meaning the file exists), start the timer
    End If
   
End Sub


Private Sub Timer1_Timer()
Timer1.Tag = Val(Timer1.Tag) - 1
    Form1.Caption = "The file exists!  Exiting in " & Timer1.Tag & " ..."
    If Timer1.Tag = "0" Then End
End Sub

also should this not be = to not -    Print #1, Mid(RET, POS1, POS2 - (POS1 + 1)) as debug keeps pulling this up.

0
Comment
Question by:pnorris99
2 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 2000 total points
ID: 16430101
Not sure what you are doing with the timer,but this should pull the correct data for the IP:


Private Sub Command1_Click()
Timer1.Enabled = False
    Form1.Caption = "Countdown stopped!"
End Sub

Private Sub Form_Load()
    Dim IE, RET
    Set IE = CreateObject("internetexplorer.application")
        IE.navigate "http://www.whatismyip.com"
        While IE.busy: DoEvents: Wend
        RET = IE.document.Title
        IE.Quit
    Set IE = Nothing

RET = Trim$(Mid$(RET, InStr(RET, "-") + 1))

    Open "c:\ipoutputfile.txt" For Output As #1
        Print #1, RET
    Close #1
   
      On Error Resume Next                    'If error arises, goto next line
   
    fil = "c:\ipoutputfile.txt"                 'Select which file to look for
   
    Open fil For Input As #1                'Try to open the file
    Close #1
   
    If Err <> 0 Then                        'If the file soesn't exist, error will ocurr
        Open fil For Output As #1           'In case of error create the missing file
        Close #1
    Else
        Command1.Caption = "Stop the timer"
        Timer1.Tag = 5
        Timer1.Interval = 1000
        Timer1.Enabled = True               'If there's no error (meaning the file exists), start the timer
    End If
   
End Sub


Private Sub Timer1_Timer()
Timer1.Tag = Val(Timer1.Tag) - 1
    Form1.Caption = "The file exists!  Exiting in " & Timer1.Tag & " ..."
    If Timer1.Tag = "0" Then End
End Sub

0
 
LVL 1

Author Comment

by:pnorris99
ID: 16430138
ahhh excellent excellent excellent, thank you so much for a quick reply.

and the timer is just to shut this down after another program has opened it up.

Thanks again
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month20 days, 5 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question