Hollow square Learn programming Visual Basic (VB.net)

Lesson:

Flow Control


Exercise:

Hollow square 27


Objetive:

Write a program which asks for a symbol, a width and displays a hollow square of that width, using that number for the outer symbol, as in this example:

Enter a symbol: 4
Enter the desired width: 3

444
4 4
444


Code:

Imports System
Public Class exercise39
    Public Shared Sub Main()
        Dim n As Integer
        Dim i, j As Integer
        Console.Write("Enter number for the border of the square: ")
        n = Convert.ToInt32(Console.ReadLine())
        Console.Write("Enter total: ")
        width = Convert.ToInt32(Console.ReadLine())
        i = 0

        While i
            Console.Write(n)
            i += 1
        End While

        Console.WriteLine()
        i = 0

        While i - 2
            Console.Write(n)
            j = 0

            While j - 2
                Console.Write(" ")
                j += 1
            End While

            Console.WriteLine(n)
            i += 1
        End While

        i = 0

        While i
            Console.Write(n)
            i += 1
        End While

        Console.WriteLine()
    End Sub
End Class