Simple Do While or For Question

Ok another easy one...

This time I am outoutting to a pole disolay using Mscomm1.
I am writing in VB6.

I wrote a small routime that loops through a listbox and sends it's current text to the comm port, moves 1 then displays again until it hits 20 (The pole displays line limit) it then moves to a second listbox and repeats. The for has 10 list boxes with checkboxes to see if that boxes text is to be displayed. Each listindex text is only a single characted, you can see how it works in the list boxes, but it stops after 1 round and just sits there, since both routies are identicle, I am at a loss as to why it stops...here is the code...


'Declare
Option Explicit
Dim Animating1 As Boolean
Dim Animating2 As Boolean

'Pause Function
Public Sub Pause(Duration As Single)
    Dim Current As Single
    Current = Timer
    Do Until Timer - Current >= Duration
        DoEvents
    Loop
End Sub

'Start the animation
Private Sub cmdAnimate_Click()
If MSComm1.PortOpen = True Then
MSComm1.Output = Chr$(31) + Chr$(17) 'Clear the Display
MSComm1.PortOpen = False 'Close the Port
Pause (0.05)
End If
MSComm1.CommPort = 1     ' sets port variable to COM1
MSComm1.PortOpen = True  ' opens the port for communication
MSComm1.Settings = "9600,N,8,1" 'sets Port Comm Settings
Animating1 = True
Animate1

End Sub

'Animation Code
Private Sub Animate1()
Animating1 = True
Animating2 = False
Pause (1)
If List1.ListCount < 20 Then
Do Until List1.ListCount = 21
List1.AddItem "*"
Loop
List1.ListIndex = 0
Do While Animating1 = True
Pause (cmbspeed.Text)
MSComm1.Output = List1.Text 'Output the Text
List1.ListIndex = List1.ListIndex + 1 'Move to the next letter
If List1.ListIndex = 20 And Animating1 = True Then
MSComm1.Output = Chr$(31) + Chr$(17) ' Clear the Display
If Check2.Value = 1 Then
  List2.ListIndex = 0
 Animating2 = True
 Animate2
End If
  End If
   Loop
 
   End If
End Sub
Private Sub Animate2()
Animating2 = True
Animating1 = False
Pause (1)
If List2.ListCount < 20 Then
Do Until List2.ListCount = 21
List2.AddItem "*"
Loop
List2.ListIndex = 0
Do While Animating2 = True
Pause (cmbspeed.Text)
MSComm1.Output = List2.Text 'Output the Text
List2.ListIndex = List2.ListIndex + 1 'Move to the next letter
If List2.ListIndex = 20 And Animating2 = True Then
MSComm1.Output = Chr$(31) + Chr$(17) ' Clear the Display
If Check10.Value = 2 Then
 List1.ListIndex = 0
 Animating1 = True
 Animate1
End If
  End If
   Loop
 
   End If
   
End Sub


Check 10 is required and greyed, therefore is alwasys 2...this is test code and animate2 will check for an animate3 etc and run through list boxes that are checked and continue until the user clicks stop which sets all animation booleans to false and closes mscomm... this runs a time or 2 and then stops..cannot figure out why as both animate1 and animate2 are the same...???


I appreciate your comments.
flosoftAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DeAnCommented:
should this line in Animate2 say Check1?? not Check10?

If Check10.Value = 2 Then
0
flosoftAuthor Commented:
No, Check 10 represents the 1st listbox and that is checked gray (2) because the first list box will always be sent when using this program...I am thinking ideally I would wrap a thin listbox with a checkbox just above it into an active x control so I could load these into an array each control having an animate (boolean) property, add,remove,moveup,movedown,text and list index...just a thought I am having.
0
flosoftAuthor Commented:
I am experimenting with the active x part, but the code still does the same exact this...so hmmmm, maybe a way to use a time??
0
DocMCommented:
The last line with "End If" must be deleted
and replaced par "End if" after line 9.


Private Sub Animate2()
Animating2 = True
Animating1 = False
Pause (1)
If List2.ListCount < 20 Then
Do Until List2.ListCount = 21
List2.AddItem "*"
Loop
List2.ListIndex = 0
End If 'Line added

Do While Animating2 = True
Pause (cmbspeed.Text)
MSComm1.Output = List2.Text 'Output the Text
List2.ListIndex = List2.ListIndex + 1 'Move to the next letter
If List2.ListIndex = 20 And Animating2 = True Then
MSComm1.Output = Chr$(31) + Chr$(17) ' Clear the Display
If Check10.Value = 2 Then
List1.ListIndex = 0
Animating1 = True
Animate1
End If
 End If
  Loop
 
'End if  'Line deleted
 
End Sub


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
flosoftAuthor Commented:
Wow...DUH..... what can I say...thanks...now I have one last thing to post....it should be fairly easy if ya want to take a crack at it...thanks again/
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.