June 2003
Intermediate to advanced
800 pages
34h 20m
English
You need to align multiple columns of fixed-width text, perhaps in a Console window or for a printout.
Pad the text with spaces using PadLeft or PadRight, according to the largest string in the column.
The String.PadLeft method adds spaces to the left of a string, whereas String.PadRight adds spaces to the right. Thus, PadLeft right-aligns a string, and PadRight left-aligns it. Both methods accept an integer representing the total length and add a number of spaces equal to the total padded length minus the length of the string.
Dim MyString As String = "Test" Dim NewString As String ' Add two spaces to the left of the string. NewString = MyString.PadLeft(6) ' You can also pad with other ...
Read now
Unlock full access