Hello once again.
Ive been tasked with writing a program the calculates the number of legos needed to create a pyramid. I have to do this in an array for a specific level ie...level 4 requires 16 legos to complete, as well as the total number of legos to complete a pyramid with 4 levels (a 4 level pyramid requires 30 legos).
I've been able to calculate the specific level here:
Try
If TextBox1.Text > 50 Then
MessageBox.Show("Level number must be 50 or less")
End If
For i = 0 To 50
pyramid(i) = TextBox1.Text
Next i
For i = 0 To 50
pyramid(i) = pyramid(i) * pyramid(i)
Next i
For i = 0 To 50
TextBox2.Text = (pyramid(i) & " Legos to build this level")
Next
However, I have yet to figure out how to:
- Clear textbox2.text when the FOR statement is true
- Calculate the total number of legos needed to create the pyramid to X levels.
I've been at this for 4 days now and regardless of what I try, I cannot get it to sum. We were given notes with the following example:
sum = array(0)
for i = 1 to 49
sum = array(i) + sum
But, I cannot, for the life of me figure out how to work this into the body of the code.
I apologize of this is an obvious noob type of question but for some reason arrays just have me stumped.
Thanks,
Jason