Export (0) Print
Expand All
Expand Minimize

Converting VBScript's CCur Function


Windows PowerShell


Definition: Returns an expression that has been converted to a Variant of subtype Currency.

CCur

Windows PowerShell uses the same data types as the .NET Framework; because the .NET Framework does not support the Currency data type that means Windows PowerShell doesn’t support this data type, either. However, while you cannot convert a variable to the Currency data type you can at least format the value so that it looks like a currency value when displayed onscreen. The following command assigns the value 13 to the variable $a and formats the value so it displays as currency:


$a = "{0:C}" -f 13

This command uses the .NET Framework currency formatting string “{0:C}” to format the value as currency (note that the value to be formatted is included as part of the -f parameter).

When you run the command and then echo back the value of $a you should get the following:


$13.00


Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft