Wednesday, 13 March 2013

Show-CurrencyGroupSeparator.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script demonstrates the use of the CurrencyGroupSeparator 
  4. .DESCRIPTION 
  5.     This script is a re-write of an MSDN sample, using PowerShell 
  6. .NOTES 
  7.     File Name  : Show-CurrencyGroupSeparator.ps1 
  8.     Author     : Thomas Lee - tfl@psp.co.uk 
  9.     Requires   : PowerShell Version 3.0 
  10. .LINK 
  11.     This script posted to: 
  12.         http://www.pshscripts.blogspot.com 
  13.     MSDN sample posted to: 
  14.          http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.currencygroupseparator%28v=vs.100%29.aspx 
  15. .EXAMPLE 
  16.     PSH> .\Show-NumberGroupSizes.ps1 
  17.     $123,456,789,012,345.00 
  18.     $123 456 789 012 345.00 
  19. #> 
  20.  
  21. # Get Number Format 
  22. $nf  = New-Object System.Globalization.CultureInfo  "en-US", $False  
  23. $nfi = $nf.NumberFormat 
  24.  
  25. # Display a value with the default separator (","). 
  26. [Int64] $myInt = 123456789012345 
  27. $myInt.ToString( "C", $nfi
  28.  
  29. # Displays the same value with a blank as the separator. 
  30. $nfi.CurrencyGroupSeparator = " " 
  31. $myInt.ToString( "C", $nfi

No comments: