Link to home
Start Free TrialLog in
Avatar of Marc333
Marc333

asked on

Waiting for a page to load before continuing

I've got an internet explorer opened in one of my forms.  What is the correct way to code, so that it waits until the entire page is completely loaded before continuing on??

ASKER CERTIFIED SOLUTION
Avatar of jjardine
jjardine
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Marc333
Marc333

ASKER

jjardine,
I'm using an older version, 2002.  I see where it is mentioned to use an addhandler.  I'm still new to .Net, but I'm guessing it looks something like:
AddHandler Explorer.DownloadBegin, AddressOf nameofevent

Is this how you handled it?  What did you use for the Addressof?
Avatar of Marc333

ASKER

sorry, I meant documentcomplete instead of downloadbegin
yes it would be just like you said.   Create a method to call and use AddHandler just like you stated..  That should work.
Avatar of Marc333

ASKER

jjardine,
I've got one problems though.  It looks like I've got it working fairly well, except once it loads the document, it looks like the handler is firing twice.  Could you take a look and tell me if I'm missing something?

Private Sub Searchbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Searchbtn.Click
        Explorer.Navigate("http://realcomponline.com/asp/search.asp?")
        AddHandler Explorer.DocumentComplete, AddressOf searchload
       
    End Sub

    Public Sub searchload(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent)
        If conn.State <> ConnectionState.Open Then conn.Open()

        Dim dr As DataRow
        Dim str As String = "Select * From MISC where ((ID) = 1);"
        Dim Miscda As New OleDbDataAdapter(str, conn)
        Dim miscds As New DataSet()
        Miscda.Fill(miscds, "Misc")


        Dim vlu As Integer

        SK("+{TAB}", 1)
        SK("{TAB}", 1)
        SendKeys.Send(" ")
        SendKeys.Send("{TAB}")
        SendKeys.Send("05071")

        SendKeys.Send("25")
        SendKeys.Send("{TAB}")
        SendKeys.Send("150")
        SendKeys.Send("{TAB}")

        'SendKeys.Send("~")

    End Sub
Avatar of Marc333

ASKER

jjardine,
I opened your example in notepad and saw how you were doing the event handler.  Only problem is that I can't use this type of method because I have several events on this form that navigate through several different pages.  And I think this would affect every one of the other events as well (correct me if I missed something)..  Though the addhandler is avoiding this issue.  
Avatar of Marc333

ASKER

jjardine,
I solved the issue and was able to use your solution by using a variable that I can set for each event.  Thanks for your help.