|
-
Dec 2nd, 2003, 08:47 PM
#1
Thread Starter
Addicted Member
Wait???
Hi in a timer tick event a web broswer navigates to a web page but i want it to wait about 2 seconds so the page can load then continue with the code. I need to keep this all in one evrnt. Any ideas? Heres the code:
VB Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
web1.Navigate("http://www.22klmqu56.com/attacklist.php?c=1&uname=&page=" & page - 1 & "&jpage=" & page & "")
'''''''***WAIT 2 SECONDS HERE***''''''''''
Dim ips As IPersistStreamInit
Dim iptr As IntPtr
Dim strm As UCOMIStream
ips = DirectCast(web1.Document, IPersistStreamInit)
iptr = Marshal.AllocHGlobal(2048)
CreateStreamOnHGlobal(iptr, True, strm)
ips.Save(strm, False)
GetHGlobalFromStream(strm, iptr)
Dim pattern As String = "(?<=\""\>)\w+(?=\<\/a\>\<\/TD\>\<TD\>)"
Dim reg As New System.Text.RegularExpressions.Regex(pattern)
Dim mcol As System.Text.regularexpressions.MatchCollection = reg.Matches(Marshal.PtrToStringAnsi(iptr))
For Each m As System.Text.RegularExpressions.Match In mcol
ListBox1.Items.Add(m.Value)
Next
Timer1.Enabled = False
End Sub
-
Dec 2nd, 2003, 08:57 PM
#2
Addicted Member
Easiest way is probably to have a private boolean which checks if it is the first or second tick.
e.g a small slice of code. (Assume bolHadFirstTick is initialized to
false)
VB Code:
If bolHadFirstTick = True Then
'Do stuff
Else
'Set the timers interval to 2 seconds
Timer1.Interval = 2000
'Change the flag
bolHadFirstTick = True
End If
Where "Do Stuff" is your code after wait 2 seconds here.
The timer will tick the first time, set it's interval to two seconds and flag the boolean to say it's had it's first tick. Then the clock will keep ticking until it hits the interval again, this time bolHadFirstTick will be true and the rest of your code can execute.
-
Dec 2nd, 2003, 09:02 PM
#3
Thread Starter
Addicted Member
ok thanks for you reply, what is bolHadFirstTick? Iys gets underlined.
-
Dec 2nd, 2003, 09:05 PM
#4
Thread Starter
Addicted Member
opps never mind, i forgot to set it as a boolean. Ecellent it works great!!
Last edited by VBGangsta; Dec 2nd, 2003 at 09:16 PM.
-Rob
-
Dec 3rd, 2003, 07:37 AM
#5
Fanatic Member
You could also probably do a sleep() but if you have it working, then cool!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|