Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stop a loop from crashing

Status
Not open for further replies.

Oderbang

Technical User
Dec 18, 2005
8
GB
if i have a loop that is never ending say a synthisizer and i want to pull out of the loop with a stop button how would i go about it here is the senario

i have 3 arrays
1st is Lights
2nd is Lights_settings
3rd is lights_order

the 1st array holds the value of each light 0-255
eg
lights0 = 0
lights1 = 10
lights3 = 255
ect

the 2nd array holds the filename of where the data that populates the array Lights is eg
Lights_settings0 = c:/lights0.txt
Lights_settings1 = c:/lights1.txt
Lights_settings2 = c:/lights2.txt
ect up to 20

the final array stores a string of numbers which is a lighting pattern eg

lights_order0 =111000444333
lights_order1 =121222333444

what the program does is takes what ever light_order youselect and reads the string of numbers in we will use Lights_order1 as an example

it then reads the first number which is 1 and and sets lights array with the values in the file that light_settings1 has it then holds for 1 secound then reads the next number in which is 2 and sets lights array with the values in the file that light_settings2 has

it does this until it gets to the end of the string of numbers then repeats again

as you can see im stuck in a never ending loop which crashes the program what i need to do is hav an interupt that can pull us out of the loop how should i do this

(hope thats not to much to take in lol)

oderbang


 
i figured out a way of doing this run a command evry soecound with counter as integer (what number in the strig you need to exacute) and pullout as boolean as a flag to pull you out of the loop

so im not actually in a loop the program just calls a sub evry secound called display which does the above

how could a do this within a sub so i can start and stop the sub calling procedure?
 
Usually its like this
Code:
[COLOR=green]' General Declarations Section[/color]
Dim StopTheLoop As Boolean

Sub Command1_Click
StopTheLoop = True
End Sub

Sub ProcessTheLoop
StopTheLoop = False
Do While True
   DoEvents
   If StopTheLoop Then Exit Do
   [COLOR=green]' Loop Processing[/color]
Loop
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top