Free for PREMIUM members
Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium
The ';' character is used to separate sections for positive, negative, and zero numbers in the format string. If there are two sections in the custom format string, the leftmost section defines the formatting of positive and zero numbers, while the rightmost section defines the formatting of negative numbers. If there are three sections, the leftmost section defines the formatting of positive numbers, the middle section defines the formatting of negative numbers, and the rightmost section defines the formatting of zero numbers.
The following example uses the format specifier for the section separator to format positive, negative, and zero numbers differently.
Visual Basic Copy Code
Dim posValue As Double = 1234
Dim negValue As Double = -1234
Dim fmt As String = "##;(##)"
Console.WriteLine(posValue.ToString(fmt)) ' Displays 1234
Console.WriteLine(negValue.ToString(fmt)) ' Displays (1234)
Open in new window
Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.