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.
The first section applies to positive values and zeros; the second applies to negative values.
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.
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.
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)