Visual Basic: String Padding – Aligning Text

Posted: January 31st, 2012 | Author: | Filed under: Visual Basic Tutorial (Series) | No Comments »

This Visual Basic tutorial continues on closely to the to the last tutorial Visual Basic String Addition – Piecing Text Together.

Next we would like to align the results. We would like the output to look as shown below:

 

 

 

 

Here is how this effect is achieved.

Console.Write(a.ToString() + ” + ” + b.toString ())
Console.Writeline(” = ” + c.ToString.Padleft(3))

 If the c has less than 3 digits add white spaces to the left.

Visual Basic Tutor



Leave a Reply