Quote (HoneyBadger @ Nov 17 2014 03:40pm)
You're going to have to use a nested for loop.
Something like this:
Code
int num = **get textbox values etc etc
int i = num;
//controls what # is printed
for(i; i >= 0; i--)
{
//this for loop controls the # of times the number is printed
for(int j = 0; j < i; j++)
{
//print out the number that you're on (ex 55555)
print(i);
}
//print out a new line to go down to next line
print(new line);
}
This will create the
55555
4444
333
22
1
Now you can figure out how to print it back down from 1-22-333-4444-55555.
There are several ways to count back UP the pyramid.
What I suggest doing is writing it all out on paper. Understand the logic before you even begin coding. Professors used to tell me this and I ignored them. Now 3 years later I do it with EVERYTHING (except this post so if it's wrong I'm blaming it on that, but it should be correct).
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim NUM1 As String = ""
Dim NUM2 = Val(TextBox1.Text)
For row As Integer = NUM2 To 1 Step -1
For column As Integer = 1 To row
NUM1 = NUM1 & row
Next
NUM1 = NUM1 & vbNewLine
Next
TextBox2.Text = NUM1
End Sub
Sub Output(Value As String)
TextBox2.Text += Value + vbCrLf
End Sub
is currently what I have and it creates
55555
4444
333
22
1
but I still dont see the logic in it