• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 161
  • Last Modified:

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.

0
pnorris99
Asked:
pnorris99
1 Solution
 
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

0
 
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now