Академический Документы
Профессиональный Документы
Культура Документы
hello
i have a question am making an update checker with a webbrowser to check if a
update to my program is available thru the webbrowsers webpages text the problem
that i am having i am getting a ton of msgboxes for my update status in the
document complete as if the webbrowser is not complete keeps firing few times i
want only one msgbox to appear any ideas on this?
Code:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, url As Variant)
Case vbYes
ShowURL ("UpdateLink")
Case vbNo
Exit Sub
End Select
End If
End Sub
Last edited by sinner0636; Apr 19th, 2015 at 01:55 PM.
Reply With Quote Reply With Quote Share on Google+ Apr 19th, 2015, 02:11 PM #2
stum stum is offline
Hyperactive Member
Join Date
Oct 2013
Posts
389
Re: Webbrowser - loading document complete more then one time
Yes, this is indeed an annoying issue.
On the few times that i did use WebBrowser control, I usually verified completion
based on (WebBrowser.ReadyState = READYSTATE_COMPLETE) combined with a 1-time
Boolean,
to avoid invoking same code more than once.
From my experience using the WebBrowser events is unreliable to say the least, to a
point where I actually preferred enabling a timer to check for .ReadyState combined
with a known .LocationURL than to trust the _Change or _DocumentCompleted \
DownloadComplete \ NavigateComplete2 \ etc.. events to fire it up.
Code:
Dim boolAlreadyExecuted As Boolean
Code:
If (WebBrowser.ReadyState = READYSTATE_COMPLETE) And Not (boolAlreadyExecuted)
Then
'...code to run...
boolAlreadyExecuted = True
End If
Reply With Quote Reply With Quote Share on Google+ Apr 19th, 2015, 02:55 PM #3
Max187Boucher Max187Boucher is offline
PowerPoster
Join Date
Aug 2011
Location
B.C., Canada
Posts
2,887
Re: Webbrowser - loading document complete more then one time
Sometimes I use a loop
Code:
Private Sub WaitForBrowser()
Do While WebBrowser1.ReadyState <> READYSTATE_COMPLETE: DoEvents: Loop
Do While WebBrowser1.Busy = True: DoEvents: Loop
End Sub
Join Date
Jan 2008
Posts
11,072
Re: Webbrowser - loading document complete more then one time
Use the BeforeNavigate2 to get your pages first. Cancel them until you get the
one(s) you want then allow those to be loaded.
If InStr(WebBrowser1.Document.body.outerText, "Install.exe")
but I am not 100% sure in your case as you are looking for something within the
document so maybe it's OK
One way to get the correct page is to put the URL in a variable:
MyURL = "www.somewebsite.com"
WebBrowser1.Navigate MyUrl
Anything I post is an example only and is not intended to be the only solution, the
total solution nor the final solution to your request nor do I claim that it is. If
you find it useful then it is entirely up to you to make whatever changes necessary
you feel are adequate for your purposes.
Reply With Quote Reply With Quote Share on Google+ Apr 20th, 2015, 10:03 AM #5
sinner0636 sinner0636 is offline
Thread Starter
Addicted Member
If WebBrowser1.Busy Then
WebBusy = True
Else
WebBusy = False
End If
End Sub
WEBBROWSER DOCUMENT COMPLETE
Code:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, url As Variant)