By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,505 Members | 1,511 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,505 IT Pros & Developers. It's quick & easy.

Time and Loop Problem

100+
P: 553
How can i write a For Loop which will run until a user hits any key


Also , i want to do something like this :

Loop Until 'Anycondition'

Update time every second :
Now(Hour)
Now(Minute)
Now(Second)

Can anyone help
Jul 25 '07 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,316
How can i write a For Loop which will run until a user hits any key


Also , i want to do something like this :

Loop Until 'Anycondition'

Update time every second :
Now(Hour)
Now(Minute)
Now(Second)

Can anyone help
You could try using DoEvents to throw control to the processor and process any keys using the KeyDown or KeyPress event.

As for the time there's a Timer event.
Jul 25 '07 #2

100+
P: 553
Rabbit

Can you give me any examples how to start?

Thanks

You could try using DoEvents to throw control to the processor and process any keys using the KeyDown or KeyPress event.

As for the time there's a Timer event.
Jul 25 '07 #3

Rabbit
Expert Mod 10K+
P: 12,316
Here's a quick and dirty example, untested.

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Dim KeyPressed As Boolean
  3.  
  4. Private Sub Form_Load()
  5.    KeyPressed = False
  6. End Sub
  7.  
  8. Private Sub SomeControl_SomeEvent()
  9.   Do Until KeyPressed = True
  10.     ...
  11.     DoEvents
  12.   Loop
  13. End Sub
  14.  
  15. Private Sub Form_KeyDown(....)
  16.   KeyPressed = True
  17. End Sub
  18.  
Jul 25 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.