Link to home
Start Free TrialLog in
Avatar of MarkW
MarkW

asked on

Graphic Delay

I want it to take five seconds for the circle to evaporate. In other words: I am trying to graphically represent a 5-second delay in the program, from one message box to another message box. What am I doing wrong?

Option Explicit
Dim Pausetime, Start, Finish, TotalTime


Private Sub Command1_Click()
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
      Pausetime = 5
      Start = Timer
      Do While Timer < Start + Pausetime
            DoEvents
            Timer1_Timer
      Loop
      Finish = Timer
      TotalTime = Finish - Start
      MsgBox "Paused for " & TotalTime & " seconds"
Else
      End
End If
End Sub

Private Sub Timer1_Timer()
Cls
Dim x As Integer
Dim y As Integer
Dim Radius As Integer
Const PI = 3.14159265
Static num As Double
FillColor = QBColor(4)
FillStyle = 0
x = ScaleWidth / 2
y = ScaleHeight / 2
Radius = ScaleWidth / 4
Circle (x, y), Radius, , num, -6.283
num = num - ((2 * PI) / 60)
Text1.Text = Str$(num)
If Abs(num) >= 6.283 Then
      num = 0
      Timer1.Enabled = 0
      Cls
End If

End Sub
Avatar of deighton
deighton
Flag of United Kingdom of Great Britain and Northern Ireland image

You seem to be calling the timer event explicitly from within the while loop.  Although the while loop will iterate for 5 seconds I would expect to see the circle vanish in much less time. Is this right ?
Perhaps you need to remove the timer_timer1 call from your while loop and set the timer interval to an appropriate value so that the event is called just enough times to wipe out the circle.
ASKER CERTIFIED SOLUTION
Avatar of deighton
deighton
Flag of United Kingdom of Great Britain and Northern Ireland 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