CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2000
    Location
    Israel,tel-aviv
    Posts
    25

    How do I make the Loop to check a Variable every 1 second?

    Hello, I need to make a while loop that checks a global Variable every 1 second. I tried to make it with No time limit, but it make the system crash,May be because it is an infinte loop.
    thanks,
    here is the code:
    While Loop_Working
    If Global_Flag = True Then
    Loop_Working = False

    GoTo Handle_Second_One
    End If
    Wend


    Eli

  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: How do I make the Loop to check a Variable every 1 second?

    Use a timer.


  3. #3
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: How do I make the Loop to check a Variable every 1 second?

    Because Visual basic only operates on a single execution thread, the code that you want to set the global flag can never be set.

    You could include a DoEvents in the loop such that whatever event sets the global variable may fire.

    HTH,
    D

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured