Visual Basic (Loops)

1 Conversation


This page isn't finished and will be edited ALOT


Loops are used when you want to run a pice of code more than once without atualy having to write out the code time after time.


In visual Basic there are 4 ways of looping...


Do Loop Until

For to Next

While Wend

(and the ever so impressive)

If then Goto


Each had it's good point, and bad points... but all do rufly the same job.

Do Loop Until

this is a built in Looping, whaits for a specific arugment, then exits

if the argument goes after the Do VB will check before each new loop

if after the Loop VB will check at the end.

Syntax


Do [{While | Until} condition]

[statements]

[Exit Do]

[statements]

Loop

Example


Do

a = a + 1

Loop Until a = 5


this will wait until a = 5 and then exit loop


This function is more simpistic and is faster to run than For to Next

For to Next

this is a loop that will count for you, and exit the loop once the counter has finsihed

Syntax


For counter = start To end [Step step]

[statements]

[Exit For]

[statements]

Next [counter]


Bookmark on your Personal Space


Conversations About This Entry

Entry

A590410

Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry


Disclaimer

h2g2 is created by h2g2's users, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the Not Panicking Ltd. Unlike Edited Entries, Entries have not been checked by an Editor. If you consider any Entry to be in breach of the site's House Rules, please register a complaint. For any other comments, please visit the Feedback page.

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more