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.
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: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)