Jump to content

For Loops


Recommended Posts

So since there is no Programming Sub-forum here on Windows Forum, I don't quite know where to post this. ;)

Anyway, I'm trying to get used to VB.NET as before all I could do was take variables from text boxes etc, send them to other pieces of the form or in a pop-up window, add, take-away numbers/letters from variables etc... Just messing around with the look of variables basically.

I'm following this tutorial on it further and have gotten up to the Loops section and can't understand how to use For loops because the tutorial is confusing me.

Could anybody explain to me what they are?

Ta. :)

Link to comment
Share on other sites

FOR loops are not particular to VB, they exist in almost every language.

Basically, a code section is executed a number of times until a certain condition is reached (usually a counter matching a margin). Example (pseudo-code)

FOR (condition)
 code line
 code line
 code line
END-FOR

Example (VB)

For counter=1 to 10
 ...
Next

'counter' above is an integer that is incremented with each loop. The increment by default is 1, but it can be anything, including negative numbers.

Things you can do in a FOR loop are numerous, for example filling an array, by using the FOR counter to address each array element.

All clear now?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy