-
Loops??
[Originally posted by David]
Can you have 2 loops within another loop?
-
Re:Loops??
[Originally posted by xterra210]
I dont think so?ÿ You'd think it would crash?ÿ You might be able tO:
do while timer1.enabled = true
ÿ ÿ do
ÿ ÿ ÿ ÿ listbox1.additem"HI"
ÿ ÿ ÿ loop
loop
but that could be simplified into
do while timer1.enabled = true
listbox1.additem "hi"
loop
-
Re:Loops??
[Originally posted by Emerson Racca]
Why not?ÿ You can have many loops within an outer loop.ÿ Maybe I don't understand the question.
-
Re:Loops??
[Originally posted by David Chapman]
The short answer is yes.
Nesting loops is fairly common in VB (and other languages).
In fact nested loops are the backbone of many sort routines and are useful for filling multidimensional arrays.
So long as you make sure that all of you loops exit (infinite loops are not fun) then you should have no problems with them.
Dave
-
Re:Loops??
[Originally posted by Chris Carta]
As David said, YES.ÿ Also, as David said, don't let it loop endlessly.ÿ Make sure you address the exit of the loop.ÿ While 'Exit Do' or 'Exit For' work just fine, they are pretty close to a GOTO.ÿ (I DON'T like 'Goto's).ÿ I often use nested loops when looking up data for a one time query versus writing a stored procedure with a cursor in Oracle.ÿ Actually, I use them in many of my programs...which is why I write a program in the first place.ÿ If the program does not need nested loops it is probably something I could figure out at a glance.
What is it that needs multiple loops?ÿ Maybe we can offer some coding examples.ÿ
Chris
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|