Window Forms Hangs While using Timer and Doevents

M

Mihir

Hi,

Copy and paste the below code.. Add Timer control and command button
to standard Exe project. Run the Code and Keep moving the mouse the
Form Freezes. Any Solution?

Option Explicit

Dim wasButtonPressed As Boolean

Private Sub Command1_Click()

wasButtonPressed = True



End Sub



Private Sub Form_Load()

Timer1.Interval = 5000

Timer1.Enabled = True

Command1.Caption = "OK"

End Sub



Private Sub Timer1_Timer()

Me.Enabled = False

wasButtonPressed = False

Command1.Caption = "Retry"

WaitForButtonPressed



End Sub





Sub WaitForButtonPressed()



Check_again:

Me.Enabled = True

If Not wasButtonPressed Then

DoEvents

GoTo Check_again

End If

Command1.Caption = "OK"

End Sub





‘ ************************
 
V

Van T. Dinh

I don't think you are talking about Microsoft Access (a
database application) Forms which is the topic of this
newsgroup.

Suggest you post to the relevant newsgroup(s) (Visual
Basic???)

HTH
Van T. Dinh
MVP (Access)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top