PDA

Click to See Complete Forum and Search --> : Looping Problem


wandoprog
Nov 4th, 2000, 11:51 PM
I have been writing this code and i can't seem to get it to work. The form contains a line and a timer. I can't get it out of the constant loop. If anyone can help it would be greatly appreciated.

The Code is like this:
General declarations
Option Explicit
Dim x1
Dim x2
Dim y1
Dim y2
Dim R
Dim G
Dim B
Dim intcount As Integer
Public Sub Intervals()
Dim make
Dim go
make = Timer
Do Until go >= make + 0.14
go = Timer
Loop

End Sub
Private Sub Command1_Click()
timer1.Enabled = True

End Sub
Private Sub Command2_Click()
timer1.Enabled = False

End Sub
Private Sub timer1_Timer()
R = Int(240 * Rnd)
G = Int(240 * Rnd)
B = Int(240 * Rnd)


Do Until timer1.Enabled = False
Randomize
Line1.BorderColor = Int(RGB(R, G, B * Rnd))
Line1.x1 = Int(Form1.Width * Rnd) + 1
Line1.y1 = Int(Form1.Height * Rnd) + 1
Line1.x2 = Int(Form1.Width * Rnd) + 1
Line1.y2 = Int(Form1.Height * Rnd) + 1
Intervals
Cls
Loop



timer1.Enabled = False

End Sub


Thank you!!!

MoMad
Nov 5th, 2000, 12:53 AM
The following line produces an indefinete loop...


...

Do Until timer1.Enabled = False
Randomize
Line1.BorderColor = Int(RGB(R, G, B * Rnd))
Line1.x1 = Int(Form1.Width * Rnd) + 1
Line1.y1 = Int(Form1.Height * Rnd) + 1
Line1.x2 = Int(Form1.Width * Rnd) + 1
Line1.y2 = Int(Form1.Height * Rnd) + 1
Intervals
Cls
Loop

...


what it need is that the timer1.enabled = false be inside the loop for the loop to be effective

example:

right before the 'Cls' you should put an if statement that checks to see if whatever ur trying to do happens so that you can place inside the code if timer1.enabled = true or false;


If something happens Then
Timer1.Enabled = False
End If


Hope that helps... msg me if it doesnt...

wandoprog
Nov 5th, 2000, 10:06 AM
I tried this to a certain extent. I must be using the wrong event inside th if then statement. I can't really figure it out yet. Any hints?? Thanks

kedaman
Nov 5th, 2000, 08:33 PM
The event wont ever get fired since you won't let it.

Put a doevents in the interval loop

Do Until go >= make + 0.14
go = Timer
Doevents
Loop while forms.count 'avoid hang up if you close your app while in the loop