JayBeeOH

Date and Currency Formats in VB.NET

Jun 12th, 2014
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.86 KB | None | 0 0
  1. ' Program:        Date and Currency Formats (DateCurrecyFormats)
  2. ' Author:         Joseph L. Bolen
  3. ' Date Created:   Jun 2014
  4. '
  5. ' Description:    Examine various cultural specific formatting for Date and Currency.
  6. '
  7. ' MSDN's Formatting Types in the .NET Framework at: http://msdn.microsoft.com/en-us/library/26etazsy(v=vs.110).aspx
  8. ' MSDN's Supported Culture Codes at: http://msdn.microsoft.com/en-us/library/hh441729.aspx
  9. '
  10. '--------------------------------------------------------------------------------------------------------------
  11. Imports System.Globalization
  12.  
  13. Module Module1
  14.  
  15.     Sub Main()
  16.  
  17.         Dim aDate As DateTime = Today
  18.         Dim enUS As New CultureInfo("en-US")    ' English (United States)
  19.         Dim enGB As New CultureInfo("en-GB")    ' English (United Kingdom)
  20.         Dim bnIN As New CultureInfo("bn-IN")    ' Bangla (India)
  21.         Dim esES As New CultureInfo("es-ES")    ' Spanish (Spain)
  22.         Dim dede As New CultureInfo("de-de")    ' German (Germany)
  23.         Dim frFR As New CultureInfo("fr-FR")    ' French (France)
  24.         Dim ja As New CultureInfo("ja")         ' Japanese
  25.  
  26.         Console.WriteLine("Date Formats: ")
  27.         Console.WriteLine()
  28.         Console.WriteLine("Short Date ""d"": " & aDate.ToString("d"))
  29.         Console.WriteLine("Short Date ""d"" with CultureInfo.InvariantCulture: " & aDate.ToString("d", CultureInfo.InvariantCulture))
  30.         Console.WriteLine()
  31.  
  32.  
  33.         Console.WriteLine("Short Date ""d"" with English (United States) Culture code ""en-US"": " & aDate.ToString("d", enUS))
  34.         Console.WriteLine("Short Date ""d"" with English (United Kingdom) Culture code ""en-GB"": " & aDate.ToString("d", enGB))
  35.         Console.WriteLine("Short Date ""d"" with Bangla (India) Culture code ""bn-IN"": " & aDate.ToString("d", bnIN))
  36.         Console.WriteLine("Short Date ""d"" with Spanish (Spain) Culture code ""es-ES"": " & aDate.ToString("d", esES))
  37.         Console.WriteLine("Short Date ""d"" with German (Germany) Culture code ""de-de"": " & aDate.ToString("d", dede))
  38.         Console.WriteLine("Short Date ""d"" with French (France) Culture code ""fr-FR"": " & aDate.ToString("d", frFR))
  39.         Console.WriteLine("Short Date ""d"" with Japanese Culture code ""ja"": " & aDate.ToString("d", ja))
  40.  
  41.         ' Pause for input to read console.
  42.         Console.WriteLine()
  43.         Console.WriteLine("Press any key to continue: ")
  44.         Console.ReadKey()
  45.  
  46.         Dim aCurrencyValue As Double = 1234.789
  47.         Console.WriteLine()
  48.         Console.WriteLine("Currency Formats: ")
  49.         Console.WriteLine()
  50.         Console.WriteLine("Currency""c"": " & aCurrencyValue.ToString("c"))
  51.         Console.WriteLine("Currency""c"" with CultureInfo.InvariantCulture: " & aCurrencyValue.ToString("c", CultureInfo.InvariantCulture))
  52.         Console.WriteLine()
  53.         Console.WriteLine("Currency""c"" with (English) United States Culture code ""en-US"": " & aCurrencyValue.ToString("c", enUS))
  54.         Console.WriteLine("Currency""c"" with English (United Kingdom) Culture code ""en-GB"": " & aCurrencyValue.ToString("c", enGB))
  55.         Console.WriteLine("Currency""c"" with Bangla (India) Culture code ""bn-IN"": " & aCurrencyValue.ToString("c", bnIN))
  56.         Console.WriteLine("Currency""c"" with Spanish (Spain) Culture code ""es-ES"": " & aCurrencyValue.ToString("c", esES))
  57.         Console.WriteLine("Currency""c"" with German (Germany) Culture code ""de-de"": " & aCurrencyValue.ToString("c", dede))
  58.         Console.WriteLine("Currency""c"" with French (France) Culture code ""fr-FR"": " & aCurrencyValue.ToString("c", frFR))
  59.         Console.WriteLine("Currency""c"" with Japanese Culture code ""ja"": " & aCurrencyValue.ToString("c", ja))
  60.  
  61.         ' Pause for input to read console.
  62.         Console.WriteLine()
  63.         Console.WriteLine("Press any key to end program: ")
  64.         Console.ReadKey()
  65.  
  66.     End Sub
  67.  
  68. End Module
Advertisement
Add Comment
Please, Sign In to add comment