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

waiting while webbrowser busy ?

hi,

another question....

I have a prog that submit a form then once submitted it load a welcome page, at this way I want to go back.

I use this :

[submitting form.....]
 Do
  DoEvents
 Loop Until Not WebBrowser1.Busy
WebBrowser1.GoBack

it give me an error :

method error, goback failed....

I think the function don't wait enough until the page is fully loaded...

is there any sure way to wait until the page be fully loaded ?

Regards,

Oliver
0
albundy
Asked:
albundy
  • 6
  • 3
  • 2
  • +6
1 Solution
 
Dave_GreeneCommented:
Isn't there a NavigateComplete property?
0
 
nutwissCommented:
yup...
0
 
nutwissCommented:
try:

Do While WebBrowser1.NavigateComplete = false
    DoEvents
Loop
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
albundyAuthor Commented:
don't work...

it didn't recognize this function :(
0
 
albundyAuthor Commented:
Isn't there a NavigateComplete property?

yep there is but didn't work too.... it doesn't wait the full load of the page
0
 
TimCotteeCommented:
You should use the Document_Complete event

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
  If URL = "Your Target URL" Then WebBrowser1.GoBack
End Sub

You don't need to use a loop or anything this way.
0
 
albundyAuthor Commented:
already tryed it... don't work too.... :(

is there any way to tell vb to wait 1 second or more ?
0
 
VincentLawlorCommented:
Use this in your code

 
Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Vin.
0
 
albundyAuthor Commented:
doesn't seems to work too :(

does sleep do events ? or does it stop all process ?

anyway it is not a good solution I think....

if anyone have a working code....pleaze :)
0
 
AzraSoundCommented:
TimCottee's solution should work.  but go ahead and try:

Do While WebBrowser.ReadyState <> READYSTATE_COMPLETE
   DoEvents
Loop

and just put an On Error Resume Next statement in the sub calling the GoBack method...the error being thrown may not even affect the operation.
0
 
VincentLawlorCommented:
How many MilliSeconds did you wait for.

Sleep just waits for the specified number of milliseconds before returning.

Vin.
0
 
albundyAuthor Commented:
sleep stop processing and that's not what I want

any way azrasound function give me an error with doc.form...

I used my previous version

Do
 DoEvents
Loop Until Not WebBrowser1.Busy

seems to be good enough.... I puted a timer, that seems to be the best.... but of course bug sometime :(

thx anyway...
0
 
AzraSoundCommented:
doc.form??
0
 
albundyAuthor Commented:
yup, I use it to submit data to a form...
0
 
AzraSoundCommented:
well that should not be related to anything i posted, but oh well, looks like you found your best solution.  good luck to you.
0
 
vikleleCommented:
Try this :

----------------------------------------------------
Dim bBackEnabled as Boolean

'for loading a page
Sub LoadPage(ByVal sURL As String)
   WebBrowser1.Navigate sURL

   Do
      'putting additional DoEvents ... don't bother
      'WebBrowser control too frequently
      DoEvents
      DoEvents
      DoEvents
   Loop Until Not WebBrowser1.Busy

End Sub

'for going back
Sub GoBack()
   Do
      DoEvents
      DoEvents
      DoEvents
   Loop Until Not bBackEnabled
   WebBrowser1.GoBack
End Sub

'for keeping track of the back button state
Private Sub WebBrowser1_CommandStateChange _
(ByVal Command As Long, ByVal bEnable As Boolean)

   If (Command = 2) Then 'back button
      bBackEnabled = bEnable
   End If

End Sub

----------------------------------------------------
Let me know if this solved your problem.

- Vikram
0
 
DanRollinsCommented:
Hi albundy,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

albundy, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 
Computer101Commented:
Placed in PAQ

Computer101
E-E Moderator
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 6
  • 3
  • 2
  • +6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now