Time and Loop Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • questionit
    Contributor
    • Feb 2007
    • 553

    Time and Loop Problem

    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
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Originally posted by questionit
    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.

    Comment

    • questionit
      Contributor
      • Feb 2007
      • 553

      #3
      Rabbit

      Can you give me any examples how to start?

      Thanks

      Originally posted by Rabbit
      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.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Here's a quick and dirty example, untested.

        [Code=vb]
        Option Explicit
        Dim KeyPressed As Boolean

        Private Sub Form_Load()
        KeyPressed = False
        End Sub

        Private Sub SomeControl_Som eEvent()
        Do Until KeyPressed = True
        ...
        DoEvents
        Loop
        End Sub

        Private Sub Form_KeyDown(.. ..)
        KeyPressed = True
        End Sub
        [/Code]

        Comment

        Working...