Write a small program that demonstrates
three ways to loop through a block of code 10 times. The program
should consist of one form with one label control and three
buttons on it. Each button will demonstrate a different way of
looping. During each iteration of each loop, you will set the
text of the label control to the iteration number. For instance,
the first time through the loop you will set the text of the
label control to "1", the second time through you will set the
text to "2", and so on. Make sure you pause between each number
so you can see each iteration.
SAMPLE CODE:
Imports
System.Threading.Thread 'this provides the "Sleep"
command to pause
Public
Class
Form1
Private
Sub
cmdForNext_Click(ByVal
sender As
System.Object,
ByVal e
As
System.EventArgs)
Handles
cmdForNext.Click
Dim
iCounter As
Integer
For
iCounter = 1 To
10
'not specifying step is the
same as Step 1
lblCount.Text = iCounter
Application.DoEvents()
'This allows the OS to give processor cycles to other
activities besides doing the loop (activities like
updating the clock and even the label in this form)
Sleep(100)
'This pauses for 100
milliseconds (1/10th of a second). It works because we
imported System.Threading.Thread
Next
End
Sub
Turn this program in by zipping
up your project directory and
placing the file in your folder on
the class FTP site. You can
get to the class FTP site
here.
When you have uploaded your project, please fill out the
form below to let me know.
Hours. (For example: 1.5 or 2)
Magic Box: (Questions, feedback, suggestions, short thought, short joke, ...)
By clicking the "Submit"
button you verify that you have
handed in your program.