FixedPointSFI class

Formats a number with a fixed count of decimal places for the F identifier.

FixedPointSFI is a format identifier class. It implements IStringFormatIdentifier and matches the identifier F or f in any case. StringHelper registers it, so {0:F} in a call to StringFormat uses it for a numeric value. The class is predeclared, and its two members are reached through the interface.

Output

The value is passed to Format$. Without a precision the format is 0.00, two decimal places. With a precision n greater than zero the format is 0. followed by n zeros. A precision of 0 is the same as none, so {0:F0} also gives two decimal places. The result has no thousands separator, and the decimal point follows the Windows regional settings.

Debug.Print StringFormat("{0:F}", 3.14159)    ' 3.14
Debug.Print StringFormat("{0:F3}", 3.14159)   ' 3.142
Debug.Print StringFormat("{0:f1}", -3.14159)  ' -3.1
Debug.Print StringFormat("{0:F0}", 2.5)       ' 2.50
Debug.Print StringFormat("{0:F2}", 12345.678) ' 12345.68

Members

  • IsIdentifierMatch returns True when the specifier’s identifier is F or f.
  • GetFormattedValue returns the value formatted as described above. It reads the specifier’s Precision.

Both are implemented as private members of the interface. GeneralNumericSFI calls this class when it chooses fixed-point notation.

See Also