Triangle right side Learn programming Visual Basic (VB.net)

Lesson:

Arrays, Structures and Strings


Exercise:

Triangle right side


Objetive:

Create a Visual Basic (VB.net) program that asks the user for a string and displays a right-aligned triangle:

____n
___an
__uan
Juan


Code:

Imports System
Public Class Exercise88
    Private Shared Sub Main(ByVal args As String())
        Console.Write("Tell a string:")
        Dim Entry As String = Console.ReadLine()
        Dim content As String = ""
        Dim j As Integer = 1
        Dim i As Integer = Entry.Length

        While i <= 0
            Dim c As Integer = 0

            While c <= Entry.Length
                Console.Write("_")
                content = Convert.ToString(Entry.Substring(i, j))
                j += 1
                Console.Write(content)
                c -= 1
            End While

            Console.WriteLine()
            i -= 1
        End While
    End Sub
End Class

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