home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 10,669 of 10,840   
   Dean Earley to John O'Flaherty   
   Re: timer control   
   15 Sep 08 09:26:14   
   
   From: dean.earley@icode.co.uk   
      
   John O'Flaherty wrote:   
   > Hello,   
   >  I'm having trouble with the timer control in VB6. I have a form with   
   > a timer control and a command button, and this simple code:   
   >   
   > Dim TimeOut As Boolean   
   >   
   > Private Sub Form_Load()   
   >     Timer1.Interval = 3000   
   >     Timer1.Enabled = True   
   > End Sub   
   >   
   > Private Sub Command1_Click()   
   > 	TimeOut = False   
   > 	While Not TimeOut   
   >    		Debug.Print TimeOut   
   > 	Wend   
   > End Sub   
   >   
   > Private Sub Timer1_Timer()   
   >     TimeOut = True   
   > End Sub   
   >   
   > I've enabled the timer, and have set an interval for it, and I would   
   > like the timer to change the state of the global variable TimeOut. On   
   > pressing command1, it goes into an infinite loop, and debugging with a   
   > breakpoint shows that the timer event is never triggered. (It gets   
   > triggered before command1 is pressed, so if you set a breakpoint you   
   > have to press the command button in the first interval to see the   
   > loop.)   
   >  Is there something obvious that I'm missing?   
      
   You need a DoEvents call in the While loop.   
   There are better ways to handle this though, maybe using the Timer()   
   function and seeing how long since the loop started.   
      
   --   
   Dean Earley (dean.earley@icode.co.uk)   
   i-Catcher Development Team   
      
   iCode Systems   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca