Padding a String - VB.NET
If you have a string, with some value in it, and you want to pad it out to a certain length, with another character you should check out the PadRight and PadLeft primitives of the String class.
The Functions take two parameters: totalWidth and paddingChar. Here are some examples:
Dim OurString As String = "thisistext" Console.WriteLine(OurString.PadRight(15, "_") ' Result: "thisistext_____"
Dim OurInteger As Integer = 99 Console.WriteLine(OurInteger.ToString.PadLeft(10, "0") ' Result: "0000000099"
Continue reading » · Rating: · Written on: 08-29-08 · 1 Comment »