CorString: PadLeft |
Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a specified total length.
Public Function PadLeft( ByRef s As String, ByVal TotalWidth As Long, Optional ByRef PaddingChar As Variant = 32 ) As String
Default: 32
The PadLeft(String,Int32, Char) method pads the beginning of the returned string.
PaddingChar can accept either AscW or ChrW$ values.
Note | This method does not modify the s parameter. Instead, it returns a new string that is padded with leading PaddingChar characters so that its total length is TotalWidth characters. |
---|
Exception | Condition |
---|---|
ArgumentOutOfRangeException | TotalWidth is less than zero. |
The following example demonstrates the PadLeft method.
Public Sub Main() Const Str As String = "Forty-Two" Const StrPad As String = "." Const CharPad As Integer = 46 Debug.Print CorString.PadLeft(Str, 15, StrPad) Debug.Print CorString.PadLeft(Str, 15, CharPad) Debug.Print CorString.PadLeft(Str, 2, StrPad) End Sub ' The previous code outputs the following. ' ' ......Forty-Two ' ......Forty-Two ' Forty-Two