Advertisement
BIastoise

Concurrent timer

Apr 19th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Dim TimerActive As Boolean
  2. Dim Message As String
  3. Dim Counter As Integer
  4.  
  5. Public Sub StartQuoteThread()
  6.     TimerActive = True
  7.     Message = "Timer running"
  8.     Counter = 0
  9.     'Application.StatusBar = DateAdd("s", 3, Time)
  10.    'Application.OnTime CDate(Application.StatusBar), "timer.Timer"
  11.    Application.OnTime Now() + TimeValue("00:00:03"), "timer.Timer"
  12. End Sub
  13.  
  14. Sub StopTest()
  15.     Call StopQuoteThread("lol")
  16. End Sub
  17.  
  18. Public Sub StopQuoteThread(Optional text = "STOPPED")
  19.     TimerActive = False
  20.     Message = text
  21.     Call EnableApplicationSettings
  22.     Call HideProgressBar
  23. End Sub
  24.  
  25. Public Sub Timer()
  26.     If TimerActive Then
  27.         Counter = Counter + 1
  28.         Debug.Print "SubThreadIteration= " & Counter
  29.         'Application.StatusBar = DateAdd("s", 3, Time)
  30.        'Application.OnTime CDate(Application.StatusBar), "timer.Timer"
  31.        Application.OnTime Now() + TimeValue("00:00:03"), "timer.Timer"
  32.     Else
  33.         If Message <> "NO-MESSAGE" Then
  34.             Msg = Message ' Define message.
  35.            Style = vbOKOnly ' Define buttons.
  36.            Title = "PAVA - SDT" ' Define title.
  37.            response = MsgBox(Msg, Style, Title)
  38.         Else
  39.             Debug.Print "SubThread Stopped"
  40.         End If
  41.     End If
  42. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement