|
-
Nov 10th, 1999, 11:04 AM
#1
Thread Starter
New Member
I'm not experienced at all with VB but I'm using it on my Senior Design project and I'm kind of stumped. I just want to be able to start a loop with a start button and end it with a stop button. I'm fine with starting the loop - It's just that while the loop is executing, the cmdStop_Click() event cannot occur because the loop is executing. Can someone tell me a)if using a command button click event to stop a loop is possible and b)how would I go about it or where can I see an example of this in action?
-
Nov 10th, 1999, 11:22 AM
#2
Use DoEvents in your Loop to Enable the Other Events/Applications to Fire, then use a Module Level Variable to Flag when to Stop, eg.
Code:
Private bStop As Boolean
Private Sub Command1_Click()
bStop = True
End Sub
Private Sub Form_Activate()
Dim I As Long
While Not bStop
I = I + 1
Caption = "Looping.. " & I
DoEvents
Wend
Caption = "Loop Canceled"
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|