How to take a break inside a sub???
glennog
Posted messages
337
Status
Member
-
Yoda -
Yoda -
Hello,
our teacher gave us an exercise and for that, he required that we use different repetitive structures in the project,
so my question is the following: I would like to use the
I thought about using a sub, but from what I've read on some forums, in VB6, it is impossible to create an ActiveX thread, while my project is a regular .exe file.
Could you please tell me if there is a way to make a pause??
Configuration: Windows 7 / Firefox 18.0
our teacher gave us an exercise and for that, he required that we use different repetitive structures in the project,
so my question is the following: I would like to use the
do while condition looploop, but I want to make a pause in my loop. Is it possible to pause in a sub directly without using a timer???
I thought about using a sub, but from what I've read on some forums, in VB6, it is impossible to create an ActiveX thread, while my project is a regular .exe file.
Could you please tell me if there is a way to make a pause??
Configuration: Windows 7 / Firefox 18.0
6 answers
-
Hello glennog,
A pause .. the quintessential annoying subject!
Pauses are always done by "timer".
It is, however, possible to simulate a pause with one or more For .. Next loops .. BUT it will be inaccurate .. sometimes it will last 2 seconds .. sometimes it will last 4 seconds .. it depends on the processor's activity.
For i= 1 To 1000000 For j= 1 To 10000 Next j Next i
In other words .. strongly discouraged.
Now, in VB 6.0, there are two kinds of timers .. the one provided with Visual Basic .. and .. the API.
Happy coding. -
Hello,
A break for what?
Normally, a Timer is used to execute an action at a predetermined time, at a determined interval.
To make a simple pause in a loop, there are several methods.
If the duration of the pause is known, use the Timer function (and not the Timer control).
Otherwise, you can create a do while...loop that waits for an event like a mouse click or a key press to continue...
See you later. -
Good evening Yoda, thank you for your post, but I didn't fully understand. By the way, when you say timer function and not control timer???
Could you be more specific? -
Good evening,
Well, you probably know that in VB6, you can place a Timer control on the form (Form) that triggers actions at certain intervals.
There is also a Timer function that returns the number of seconds elapsed since midnight.
You can use this function to pause for x seconds in the program's execution. For example:
Do While condition = True Instruction1 Instruction2 'Pause for 5 seconds t0=Timer + 5 While Timer < t0 Do Events Wend Instruction3 Instruction4 Loop
See you later. -
Okay, thanks, I will try the code and let you know the outcome.
-
But tell me, here in your example, what type do I declare t0 as?