Function Formats Justifies Class

JustifyText

Justify a line of text according to the fjJustify formatting codes documented at the beginning of this module. Performs left, right, center, and fill justification on a string containing a line of text.

Signature (Visual Basic / VBA)

Public Function JustifyText( _
      ByVal vValue As Variant _
    , ByVal vWidth As Variant _
    , Optional ByVal vCodes As Variant _
    , Optional ByVal vFillString As Variant _
    ) As Variant

Code Example

    JustifyText("This is a test.", 20, JustifyRight, "-") = "-----This is a test."
    JustifyText("This is a test.", 18, JustifySpread, " ") = "This  is  a  test."

Parameters

Parameter Description
vValue String containing the line of text which is to be justified. Function returns Null if vValue is Null.
vWidth The desired length/width of the string after it has been formatted. Function returns Null if vWidth if Null or cannot be fixed up to a String.
vCodes Any meaningful combination of the formatting codes available through the Justify properties of this Class. Defaults an empty string (the absence of any specific formatting codes) if vCodes is missing or Null or cannot be fixed up to a String.
vFillString The string used to fill vValue if its length is less than the desired width vWidth. vCodes defaults to the space character (Chr$(32) if it is missing or Null or cannot be fixed up to a String. Function returns Null if vValue cannot be fixed up to a String.

Notes & Version History

Note See the WrapText function which will format a string containing more than one line of text.