
December 9th, 2012, 11:34 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 8
Time spent in forums: 2 h 17 m 34 sec
Reputation Power: 0
|
|
|
Need Help with Code
I had to write a code that displays this
*****
*****
*****
I had to use the For...Next statements. The code works, except when I hit the start button to calculate it displays this
*****
*****
*****
If I hit it again it adds to it.
*****
*****
*****
*****
*****
*****
and it keeps going if I keep hitting the button. How can I stop it at the first calculation?
Here is the code.
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
For x As Integer = 1 To 3 Step 3
For y As Integer = 1 To 9 Step 2
asterisksLabel.Text = asterisksLabel.Text & "*"
Next y
asterisksLabel.Text = asterisksLabel.Text & ControlChars.NewLine
Next x
For x As Integer = 1 To 3 Step 2
For y As Integer = 1 To 9 Step 2
asterisksLabel.Text = asterisksLabel.Text & "*"
Next y
asterisksLabel.Text = asterisksLabel.Text & ControlChars.NewLine
Next x
End Sub
|