Inet control refreshing problem !?!?
Hello, I use this code to monitor some changes on site index,
evrything works OK when first time getting data, and when I
use it in loop mode, all info remains same but it chages on site!
What is wrong with this code, why he dont read site info in loop mode?
VB Code:
lStart = 1
lEnd = 1
sFindStart = "news this hour:"
sFindEnd = vbNewLine
sSource = ""
sSource = Inet1.OpenURL(GetSetting(App.EXEName, "Settings", "text1", ""))
Do While Inet1.StillExecuting
DoEvents
Loop
Inet1.Execute , "CLOSE"
lStart = InStr(lStart, sSource, sFindStart, vbTextCompare)
If lStart Then
lStart = lStart + Len(sFindStart)
lEnd = InStr(lStart, sSource, sFindEnd, vbTextCompare)
If lEnd > lStart Then
Text1.Text = Mid$(sSource, lStart, lEnd - lStart)
Else
Debug.Print "Cant find text."
End If
Else
Debug.Print "Cant find text."
End If
End If
So Text1.Text remains same when using loop mode, WHY :confused:
And web site info changes
Re: Inet control refreshing problem !?!?
That Do loop doesn't help you much - when Inet is done, it stops "looping". Do you have this in a timer or some other sub?
Re: Inet control refreshing problem !?!?
I have Timer, and all posted above code is in main do loop, there are
different option's and only this one not working correctly ( stuck on old info )!
Re: Inet control refreshing problem !?!?
Quote:
Originally Posted by gavio
That Do loop doesn't help you much - when Inet is done, it stops "looping".
I think you'll find that's the *point* of the do loop...without it, it'd try to read partial source...that's there to wait until inet's finished then do stuff with the HTML source downloaded...a trick I use often
Re: Inet control refreshing problem !?!?
VB Code:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Sub Pause(Milliseconds As Single)
Dim sngEnding As Single
sngEnding = Timer + (Milliseconds / 1000)
Do Until Timer >= sngEnding
Sleep 1
DoEvents
Loop
End Sub
here is problem....
VB Code:
Private Sub Timer1_Timer()
On Error Resume Next
Do
If Option1.Value = True Then
lStart = 1
lEnd = 1
sFindStart = "news this hour:"
sFindEnd = vbNewLine
sSource = ""
sSource = Inet1.OpenURL(GetSetting(App.EXEName, "Settings", "text1", ""))
Do While Inet1.StillExecuting
DoEvents
Loop
Inet1.Execute , "CLOSE"
lStart = InStr(lStart, sSource, sFindStart, vbTextCompare)
If lStart Then
lStart = lStart + Len(sFindStart)
lEnd = InStr(lStart, sSource, sFindEnd, vbTextCompare)
If lEnd > lStart Then
Text1.Text = Mid$(sSource, lStart, lEnd - lStart)
Else
Debug.Print "Cant find text."
End If
Else
Debug.Print "Cant find text."
End If
End If
pause 2000
If Option2.Value = True Then
another code...
...
Loop Until Text2.Text <> Text1.Text