Results 1 to 4 of 4

Thread: Timer and Webbrowser

  1. #1

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    54

    Timer and Webbrowser

    How can I incorporate the timer so once a page loads the timer activates, waits a few seconds then I tell my program what to do next.

    I tried this code but it didnt work:

    Code:
            Timer1.Interval = 5000
            Timer1.Enabled = True
            Timer1.Start()
            WebBrowser1.Navigate("www.google.com")
            Timer1.Stop()
    Can you help?

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Timer and Webbrowser

    Move the timer stuff to the WebBrowser.DocumentCompleted handler.

    Timer1.Interval = 5000
    Timer1.Enabled = True
    Timer1.Start()
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    54

    Re: Timer and Webbrowser

    I tried this:

    vb Code:
    1. Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    2.            If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
    3.                 Timer1.Interval = 5000
    4.                 Timer1.Enabled = True
    5.                 Timer1.Start()
    6.                 WebBrowser1.Navigate("www.google.com")
    7.  
    8.             End If
    9.  
    10.  
    11.     End Sub

    But it automatically redirected to Google.com and it didnt wait for the previous site to complete loading, then wait 5 seconds.

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Timer and Webbrowser

    MOVE this WebBrowser1.Navigate("www.google.com") to the Tick event of the Timer.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width