PadLeft, PadRight and PadCenter
Public Class Tester
Public Shared Sub Main
Dim content1 As String
Dim content2 As String
Dim content3 As String
Dim content4 As String
content1 = "Not padded"
content2 = "PadLeft".PadLeft(50)
content3 = "PadRight".PadRight(50)
content4 = "PadCenter"
content4 = content4.PadLeft((50 + _
content4.Length) \ 2).PadRight(50)
Console.WriteLine(String.Format("{0}{4}{1}{4}{2}{4}{3}", _
content1, content2, content3, content4, vbNewLine))
End Sub
End Class
Not padded
PadLeft
PadRight
PadCenter
PadLeft, PadRight and PadCenter with dot
Public Class Tester
Public Shared Sub Main
Dim content1 As String
Dim content2 As String
Dim content3 As String
Dim content4 As String
content1 = "Not padded"
content2 = "PadLeft".PadLeft(50, "."c)
content3 = "PadRight".PadRight(50, "."c)
content4 = "PadCenter"
content4 = content4.PadLeft((50 + content4.Length) \ 2, _
"."c).PadRight(50, "."c)
Console.WriteLine(String.Format("{0}{4}{1}{4}{2}{4}{3}", _
content1, content2, content3, content4, vbNewLine))
End Sub
End Class
Not padded
...........................................PadLeft
PadRight..........................................
....................PadCenter.....................
String.Pad
public class Test
public Shared Sub Main
Dim strLeftPad, strRightPad As String
strLeftPad = "[" & "Visual Basic Express".PadLeft(28) & "]"
strRightPad = "[" & "Visual Basic Express".PadRight(28) & "]"
Console.WriteLine(strLeftPad & vbCrLf & strRightPad)
strLeftPad = "[" & "Visual Basic Express".PadLeft(28, "@") & "]"
strRightPad = "[" & "Visual Basic Express".PadRight(28, ".") & "]"
Console.WriteLine(strLeftPad & vbCrLf & strRightPad)
End Sub
End class
[ Visual Basic Express]
[Visual Basic Express ]
[@@@@@@@@Visual Basic Express]
[Visual Basic Express........]