CorString: PadRight |
Returns a new string that left-aligns the characters in this string by padding them on the right with a specified Unicode character, for a specified total length.
Public Function PadRight( ByRef s As String, ByVal TotalWidth As Long, Optional ByRef PaddingChar As Variant = 32 ) As String
Default: 32
The PadRight(String,Int32, Char) method pads the end 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 trailing PaddingChar characters so that its total length is TotalWidth characters. |
---|
Exception | Condition |
---|---|
ArgumentOutOfRangeException | TotalWidth is less than zero. |
The following example demonstrates the PadRight method.
Public Sub Main() Const Str As String = "Forty-Two" Const StrPad As String = "." Const CharPad As Integer = 46 Debug.Print CorString.PadRight(Str, 15, StrPad) Debug.Print CorString.PadRight(Str, 15, CharPad) Debug.Print CorString.PadRight(Str, 2, StrPad) End Sub ' The previous code outputs the following. ' ' Forty-Two...... ' Forty-Two...... ' Forty-Two