Pause state?

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Dec 2008
Posts: 8
Reputation: Zermoth is an unknown quantity at this point 
Solved Threads: 0
Zermoth's Avatar
Zermoth Zermoth is offline Offline
Newbie Poster

Pause state?

 
0
  #1
Dec 11th, 2008
Is there a way to enter a pause state between commands running?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 304
Reputation: aktharshaik is an unknown quantity at this point 
Solved Threads: 37
aktharshaik's Avatar
aktharshaik aktharshaik is offline Offline
Posting Whiz

Re: Pause state?

 
0
  #2
Dec 12th, 2008
if u have 2 commands and want the 2nd command to run after a certain interval of time, u can use the timer control.

During design time; set its interval property to ur required time of pause (in milliseconds), set Enable property to false

Now for the coding part, after the 1st command statement just Enable the timer. In the Timer() event of the timer, write the 2nd Command followed by Timer1.Enabled = False for the Timer control.

I assume that u have two command buttons and one timer control on your form. When the first command button is clicked it executes the statements and in the last statement of this event, the timer control is enabled. Once the timer control is enabled the counting starts and after an interval of 5000 ms the Timer() event is fired. There the call for the second command button click event is placed. After the execution of which the timer control is disabled.

If u dont disable the Timer control after the call for the Command2 click event, then Timer() event it is fired again and again for every 5000 ms.

Eg:
  1. Private Sub Form_Load()
  2. Timer1.Interval = 5000 'for 5 seconds
  3. Timer1.Enabled = False
  4. End Sub
  5.  
  6. Private Sub Command1_Click()
  7. 'Write your code for the first command
  8. Timer1.Enabled = True
  9. End Sub
  10.  
  11. Private Sub Timer1_Timer()
  12. Call Command2_Click
  13. Timer1.Enabled = False
  14. End Sub
  15.  
  16. Private Sub Command2_Click()
  17. 'Write your code for the Second Command
  18. End Sub
Last edited by aktharshaik; Dec 12th, 2008 at 1:30 am.
Regards
Shaik Akthar
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Pause state?

 
0
  #3
Dec 12th, 2008
Hi,

use SLEEP API

Declare this at the top of the Form's Code window (After Option Explicit)

  1. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  2.  
  3. 'To Pause/Sleep for 10 seconds, write this code:
  4. Sleep(10000)

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 8
Reputation: Zermoth is an unknown quantity at this point 
Solved Threads: 0
Zermoth's Avatar
Zermoth Zermoth is offline Offline
Newbie Poster

Re: Pause state?

 
0
  #4
Dec 15th, 2008
Thanks will try both

Should have explained what I was doing better.

Am running an update system over network to 2 remote TabletPC (when they get connected) been trying to show what was going on, what stage was getting worked on and completed.

I just put in a open dialog/form box for doing a refresh on other window then closing it and continuing.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC