2

Make a program that reads a positive integer no greater than 10, and prints a triangle of numbers as follows:
If the number read were 5, then it should print:

1

22

333

4444

55555

The program must reread another number until the number entered is greater than 10.

I have tried this, but I don't know if it is correct:

    Dim num As Integer
    Dim i As Integer
    num = InputBox(" enter a number")
    For i = 1 To num Step 1
        If i = 1 Then

            ListBox1.Items.Add(1)

        ElseIf i = 2 Then
            ListBox1.Items.Add(22)

        ElseIf i = 3 Then
            ListBox1.Items.Add(333)
        ElseIf i = 4 Then
            ListBox1.Items.Add(4444)
        ElseIf i = 5 Then
            ListBox1.Items.Add(55555)
        ElseIf i = 6 Then
            ListBox1.Items.Add(666666)

        ElseIf i = 7 Then
            ListBox1.Items.Add(7777777)
        ElseIf i = 8 Then
            ListBox1.Items.Add(88888888)
        ElseIf i = 9 Then
            ListBox1.Items.Add(999999999)
        ElseIf i = 10 Then
            ListBox1.Items.Add(1010101010101010101010)

        End If
    Next
Sep Roland
  • 33,889
  • 7
  • 43
  • 76

0 Answers0