|
-
Mar 29th, 2008, 11:18 AM
#1
Thread Starter
Lively Member
Webbrowser: Need help on delays inside the loop
Hi everyone!
I have a webbrowser control that opens a website and automatically fill in the textboxes on the forms. I am done with that part but im having problems with the loop.
The data are stored in the database where i populate it using Msflexgrid. And i use two textboxes for ranges like process 1-5 or 10-20... etc coz i have more than 10,000 records.
I want to leave my computer to process it but for the sake of testing i put number ranges that is incorporated in my loop.
Code:
Dim x As Long ' loop counter
tempnum = CLng(txtFrom.Text)
For x = CLng(txtFrom.Text) To CLng(txtTo.Text)
With WebBrowser1
.Document.All("Add").Click
' error on this part coz the above code is not yet completed
.Document.All("Firstname").Value = MSFlexGrid1.TextMatrix(tempnum, 1)
.Document.All("Lastname").Value = MSFlexGrid1.TextMatrix(tempnum, 2)
.Document.All("Save").Click
tempnum = tempnum + 1
End With
Next x
I'm having problems with the click event coz it will not wait for the document to complete before firing the next command. Is there a workaround for this delay without moving the rest of the function to "WebBrowser1_DocumentComplete" event?
-
Mar 29th, 2008, 11:31 AM
#2
Re: Webbrowser: Need help on delays inside the loop
There are several possible solutions. The easiest to try is
Code:
Dim x As Long ' loop counter
tempnum = CLng(txtFrom.Text)
For x = CLng(txtFrom.Text) To CLng(txtTo.Text)
With WebBrowser1
.Document.All("Add").Click
DoEvents
' error on this part coz the above code is not yet completed
.Document.All("Firstname").Value = MSFlexGrid1.TextMatrix(tempnum, 1)
.Document.All("Lastname").Value = MSFlexGrid1.TextMatrix(tempnum, 2)
.Document.All("Save").Click
tempnum = tempnum + 1
End With
Next x
-
Mar 29th, 2008, 11:45 AM
#3
Thread Starter
Lively Member
Re: Webbrowser: Need help on delays inside the loop
I've tried it. it will not work.
Is there a workaround for usinga a delay without moving the rest of the function to "WebBrowser1_DocumentComplete" event?
like this for example. it works with no prob.
Code:
Dim x As Long ' loop counter
tempnum = CLng(txtFrom.Text)
For x = CLng(txtFrom.Text) To CLng(txtTo.Text)
With WebBrowser1
.Document.All("Add").Click 'clicking add button
'the function is located
'on document complete below
.Document.All("Save").Click 'clicking save button
tempnum = tempnum + 1
End With
Next x
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WebBrowser1.Object) Then
If URL = "https://www.expected_URL_To_Trigger_A_Function.com" Then
.Document.All("Firstname").Value = MSFlexGrid1.TextMatrix(tempnum, 1)
.Document.All("Lastname").Value = MSFlexGrid1.TextMatrix(tempnum, 2)
End If
End If
End Sub
The problem with this is I have a loop is rhere any other way for the next command to wait until document is completed?
-
Mar 29th, 2008, 02:18 PM
#4
Re: Webbrowser: Need help on delays inside the loop
 Originally Posted by Erroneous
The problem with this is I have a loop is rhere any other way for the next command to wait until document is completed?
Define "completed"
-
Mar 29th, 2008, 03:22 PM
#5
Thread Starter
Lively Member
Re: Webbrowser: Need help on delays inside the loop
completed as in "html document is completely loaded" before firing the next command.
By the way, im browsing a secure page https and it seems that some button is not responding to what its suppose to do. Sometimes I need to hit F5 to refresh it and it will be ok. Is there a tip when using secure pages?
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
|