WAN IP retrieve no longer working

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.

LVL 1
pnorris99Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vinnyd79Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pnorris99Author Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.