Display string representations of numbers for en-us culture
Option Strict On
Imports System.Globalization
Imports System.Threading
Module NumericFormats
Public Sub Main()
Dim ci As New CultureInfo("en-us")
Dim floating As Double = 99999.123456
Console.WriteLine("C: {0}",floating.ToString("C", ci))
Console.WriteLine("E: {0}",floating.ToString("E03", ci))
Console.WriteLine("F: {0}",floating.ToString("F04", ci))
Console.WriteLine("G: {0}",floating.ToString("G", ci))
Console.WriteLine("N: {0}",floating.ToString("N03", ci))
Console.WriteLine("P: {0}",(floating/10000).ToString("P02", ci))
Console.WriteLine("R: {0}",floating.ToString("R", ci))
Console.WriteLine()
Dim integral As Integer = 8395
Console.WriteLine("C: {0}",integral.ToString("C", ci))
Console.WriteLine("D: {0}",integral.ToString("D6"))
Console.WriteLine("E: {0}",integral.ToString("E03", ci))
Console.WriteLine("F: {0}",integral.ToString("F01", ci))
Console.WriteLine("G: {0}",integral.ToString("G", ci))
Console.WriteLine("N: {0}",integral.ToString("N01", ci))
Console.WriteLine("P: {0}",(integral/10000).ToString("P02", ci))
Console.WriteLine("X: 0x{0}",integral.ToString("X", ci))
Console.WriteLine()
End Sub
End Module
Related examples in the same category