Converts Integer to string using the specified format. : Integer Format « Data Types « VB.Net






Converts Integer to string using the specified format.

 

Imports System
Imports Microsoft.VisualBasic

Module MainClass

    Sub Main( )
            Dim value As Integer = -99999
            Dim specifier As String
           
            specifier = "G"
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))

            specifier = "C"
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))

            specifier = "D8"
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))

            specifier = "E4"
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))

            specifier = "e3"
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))

            specifier = "F"
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))

            specifier = "N"
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))

            specifier = "P"
            Console.WriteLine("{0}: {1}", specifier, (value/100000).ToString(specifier))

            specifier = "X"
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))

            specifier = "0,0.000"
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))

            specifier = "#,#.00#;(#,#.00#)"
            Console.WriteLine("{0}: {1}", specifier, (value*-1).ToString(specifier))
    End Sub 
End Module

   
  








Related examples in the same category

1.Integer format: N1
2.Integer format: x
3.Integer format: X
4.Integer format: X8
5.Large Integer format: X
6.Hex integer format: X2
7.CultureInfo("en-us") and Integer format: C
8.CultureInfo("en-us") and Integer format: D6
9.CultureInfo("en-us") and Integer format: E03
10.CultureInfo("en-us") and Integer format: F01
11.CultureInfo("en-us") and Integer format: G
12.CultureInfo("en-us") and Integer format: N01
13.CultureInfo("en-us") and Integer format: P02
14.CultureInfo("en-us") and Integer format: X
15.Standard Numeric Format Strings for negative value: D
16.Standard Numeric Format Strings for positive value: D8
17.Standard Numeric Format Strings: F3
18.Display value using default formatting
19.Display value with 3 digits and leading zeros
20.Display value with 1 decimal digit
21.Display value as hexadecimal
22.Display value with eight hexadecimal digits
23.Display Integer Value in Binary Octal and Hex forms
24.Converts Integer to string using the specified culture-specific format information.
25.Converts Integer to string using the specified format and culture-specific format information.
26.Converts Integer to string representation.
27.Convert Integer to String: D3, N1, X2, X8
28.Convert Integer to its Binary, Octal, Hex forms
29.Display value using default formatting
30.Display value with 3 digits and leading zeros
31.Display value with 1 decimal digit