Results 1 to 2 of 2

Thread: timer problem?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    377

    timer problem?

    Can someone tell me why this coding doesn't work properly? It's suppose to navigate to news.com then if the page takes more than 1second to load, it should be Stopped then and navigate to microsoft.com should be done. Is there something wrong with my timer?

    Code:
    Private Sub cmdStart_Click()
    On Error Resume Next
    
    WebBrowser1.Navigate "http://www.news.com"
    
        Dim Check As Long
        Check = timTimer
        timTimer.Enabled = True
        timTimer.Interval = 1000 '*one second
    
      timTimer.Enabled = True
      If WebBrowser1.Busy And timTimer - Check > 1000 Then
      WebBrowser1.Stop
      WebBrowser1.Navigate "http://www.microsoft.com"
      End If
    
      Do
        DoEvents
      Loop Until Not WebBrowser1.Busy
    
    End Sub
    
    Private Sub timTimer_Timer()
        If WebBrowser1.Busy = False Then
            timTimer.Enabled = False
            Me.Caption = WebBrowser1.LocationName
        Else
            Me.Caption = "Working..."
        End If
    End Sub

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    VB Code:
    1. Private Sub cmdStart_Click()
    2. On Error Resume Next
    3.  
    4. WebBrowser1.Navigate "http://www.news.com"
    5.  
    6.     Dim Check As Long
    7.     Check = timTimer
    8.     timTimer.Enabled = True
    9.     timTimer.Interval = 1000 '*one second
    10.  
    11.   [b]timTimer.Enabled = True[/b]
    12.   If WebBrowser1.Busy And timTimer - Check > 1000 Then
    13.   WebBrowser1.Stop
    14.   WebBrowser1.Navigate "http://www.microsoft.com"
    15.   End If
    16.  
    17.   Do
    18.     DoEvents
    19.   Loop Until Not WebBrowser1.Busy
    20.  
    21. End Sub
    22.  
    23. Private Sub timTimer_Timer()
    24.     If WebBrowser1.Busy = False Then
    25.         timTimer.Enabled = False
    26.         Me.Caption = WebBrowser1.LocationName
    27.     Else
    28.         Me.Caption = "Working..."
    29.     End If
    30. End Sub

    You do know this doesn't pause execution for a second, right? It goes right tothe next line.
    Last edited by The Hobo; Jun 8th, 2002 at 12:08 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

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