Triangle V2 Learn programming Visual Basic (VB.net)

Lesson:

Arrays, Structures and Strings


Exercise:

Triangle V2


Objetive:

Write a Visual Basic (VB.net) program to ask the user for his/her name and display a triangle with it, starting with 1 letter and growing until it has the full length:

Enter your name: Juan
J
Ju
Jua
Juan


Code:

Imports System
Public Class exercise83
    Public Shared Sub Main()
        Dim n, ancho, alto As Integer
        Dim row, column As Integer
        Console.Write("Introduce un número: ")
        n = Convert.ToInt32(Console.ReadLine())
        Console.Write("Introduce la anchura: ")
        ancho = Convert.ToInt32(Console.ReadLine())
        alto = ancho

        For row = 0 To alto - 1

            For column = 0 To ancho - 1
                Console.Write(n)
            Next

            Console.WriteLine()
            ancho -= 1
        Next
    End Sub
End Class

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.