-
Apr 3rd, 2014, 12:40 PM
#1
Thread Starter
New Member
For ... Next Looping Problems
My teacher did not explain for next looping. She gave an example on a completely different looping structure:
Private Sub btnDo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDo.Click
Dim intNum, intSum As Integer
Do intSum += intNum ‘accumulator/running total
intNum += 2 ‘update intNum
Loop While (intNum <= 50)
Me.lblDoAnswer.Text = intSum.ToString
End Sub
But she wants this in a For.. Next Loop? My teacher sucks at teaching, I need help
-
Apr 3rd, 2014, 12:47 PM
#2
Re: For ... Next Looping Problems
In your loop it loops until intNum hits 51. So to structure your for/next loop, you will loop from the beginning value of intNum to 51... but it looks like increment intNum by 2 in your loop, because of this you must also set the Step of the for/next loop to 2:
Code:
For x As Integer = intNum To 51 Step 2
Next
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
|
Click Here to Expand Forum to Full Width
|