Share via


Featured TechNet Wiki Article - Visual Basic: How to Draw a Border of ASCII Text in a Console Application

We recently featured this Visual Basic article on the home page of TechNet Wiki. It's the Visual Basic Guru gold medal winner for October!

 

 

 

Visual Basic: How to Draw a Border of ASCII Text in a Console Application

By Reed Kimble
December 8, 2013

The Console Application is a handy way to write simple utility programs that do not require much in the way of a user interface. Typically a Console Application uses a command-line interface where the user types commands into the window, presses enter, and the window reports back lines of text with the result of the command execution. But before there were programs...

 

Here's an excerpt:

This article will take a slightly more advanced approach and will use an algorithm to layout the proper sequence of ASCII characters based on a series of defined rectangles representing the window frame.  The easiest way to describe this might be with a picture:

Here you can see a double-line border around the inside of the window, with a box at the top and bottom.  This frame would be described by the rectangles:

Dim border ``AsNew Rectangle(0, 0, Console.WindowWidth, Console.WindowHeight)

Dim title ``AsNew Rectangle(0, 0, Console.WindowWidth, 3)

Dim command ``AsNew Rectangle(0, Console.WindowHeight - 3, Console.WindowWidth, 3)

While the approach presented here may be "slightly more advanced", the algorithm used is straight-forward and easy to follow so an even more (or truly) advanced version could still be crafted.

 

 

Read the rest of the article here:

Visual Basic: How to Draw a Border of ASCII Text in a Console Application

 

 

Thanks to Reed for this great article!

   - Ninja Ed

Comments

  • Anonymous
    December 13, 2013
    This article, plus the related "How to Write to a Console Window without Wrapping Text" (also by Reed) are among the best I've seen. Great formatting in the articles and clever code. Well worth highlighting as excellent examples.

  • Anonymous
    December 16, 2013
    The comment has been removed