Hi VB.net gurus, I'm new in programming especially in vb.net and I have a problem displaying the following using for-next loops:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
...and so on...
initially I wrote this code
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim row As Integer
Dim col As Integer
Dim txtNumber As Integer = CInt(TextBox1.Text)
Dim txtOutput As String
For row = 1 To txtNumber Step 1
For col = row To (row + (row - 1))
txtOutput = txtOutput & " " & col
Next
txtOutput = txtOutput & vbCrLf
Next
Label1.Text = txtOutput
End Sub
the out put is this
1
2 3
3 4 5
4 5 6 7
5 6 7 8 9
... and so on...
Kindly help me on this one please to improve my knowledge in vb.net
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
...and so on...
initially I wrote this code
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim row As Integer
Dim col As Integer
Dim txtNumber As Integer = CInt(TextBox1.Text)
Dim txtOutput As String
For row = 1 To txtNumber Step 1
For col = row To (row + (row - 1))
txtOutput = txtOutput & " " & col
Next
txtOutput = txtOutput & vbCrLf
Next
Label1.Text = txtOutput
End Sub
the out put is this
1
2 3
3 4 5
4 5 6 7
5 6 7 8 9
... and so on...
Kindly help me on this one please to improve my knowledge in vb.net