Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Different Formats for Different Numeric Values (Format Function)

A user-defined format expression for numbers can have from one to three sections separated by semicolons. If the style argument of the Format function contains one of the Predefined Numeric Formats, only one section is allowed.

If you use This is the result
One section only The format expression applies to all values.
Two sections The first section applies to positive values and zeros; the second applies to negative values.
Three sections The first section applies to positive values, the second applies to negative values, and the third applies to zeros.

The following example has two sections: the first defines the format for positive values and zeros; the second section defines the format for negative values. Since the Style argument of the Format function takes a string, it is enclosed by quotation marks.

"$#,##0;($#,##0)"

If you include semicolons with nothing between them, the missing section is printed using the format of the positive value. For example, the following format displays positive and negative values using the format in the first section and displays Zero if the value is zero.

"$#,##0;;\Z\e\r\o"

Requirements

Namespace: Microsoft.VisualBasic

Module: Strings

Assembly: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)

See Also

Format Function

Show:
© 2015 Microsoft