Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How can i just make even integers 10-16 instead 10,11,12,13,14,15,16 Public Clas

ID: 3580861 • Letter: H

Question

How can i just make even integers 10-16 instead 10,11,12,13,14,15,16

Public Class MainForm
Private Sub displayButton_Click(sender As Object, e As EventArgs) Handles displayButton.Click
Dim Product As Integer
For i As Integer = 10 To 16

tableLabel.Text = tableLabel.Text & ControlChars.NewLine & i.ToString
For j As Integer = 2 To 5
Product = i * j
tableLabel.Text = tableLabel.Text & "" & Product

Next j
Next i

End Sub

Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click
Me.Close()
End Sub
End Class

Explanation / Answer

For ... Next by default takes a step of 1. But it can be managed by exclusively specifying the step keyword.

So, if you want to make the step 2 instead of 1, we have to specify that in the loop. So, this is how you can achieve your requirement, assuming everything else working fine:

Public Class MainForm
Private Sub displayButton_Click(sender As Object, e As EventArgs) Handles displayButton.Click
Dim Product As Integer
For i As Integer = 10 To 16 Step 2

tableLabel.Text = tableLabel.Text & ControlChars.NewLine & i.ToString
For j As Integer = 2 To 5
Product = i * j
tableLabel.Text = tableLabel.Text & "" & Product

Next j
Next i

End Sub

Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click
Me.Close()
End Sub
End Class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote