Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Decimal.FromOACurrency Method

Converts the specified 64-bit signed integer, which contains an OLE Automation Currency value, to the equivalent Decimal value.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static decimal FromOACurrency (
	long cy
)
public static Decimal FromOACurrency (
	long cy
)
public static function FromOACurrency (
	cy : long
) : decimal
Not applicable.

Parameters

cy

An OLE Automation Currency value.

Return Value

A Decimal that contains the equivalent of cy.

The following code example uses the FromOACurrency method to convert Int64 fields that contain OLE Automation Currency values to the equivalent Decimal numbers.

// Example of the decimal.FromOACurrency method. 
using System;

class DecimalFromOACurrencyDemo
{
    const string dataFmt = "{0,21}{1,25}";

    // Display the decimal.FromOACurrency parameter and decimal result.
    public static void ShowDecimalFromOACurrency( long Argument )
    {
        decimal decCurrency = decimal.FromOACurrency( Argument );

        Console.WriteLine( dataFmt, Argument, decCurrency );
    }

    public static void Main( )
    {
        Console.WriteLine( "This example of the " +
            "decimal.FromOACurrency( ) method generates \nthe " +
            "following output. It displays the OLE Automation " +
            "Currency \nvalue as a long and the result as a " +
            "decimal.\n" );
        Console.WriteLine( dataFmt, "OA Currency", "Decimal Value" );
        Console.WriteLine( dataFmt, "-----------", "-------------" );

        // Convert OLE Automation Currency values to decimal objects.
        ShowDecimalFromOACurrency( 0L );
        ShowDecimalFromOACurrency( 1L );
        ShowDecimalFromOACurrency( 100000L );
        ShowDecimalFromOACurrency( 100000000000L );
        ShowDecimalFromOACurrency( 1000000000000000000L );
        ShowDecimalFromOACurrency( 1000000000000000001L );
        ShowDecimalFromOACurrency( long.MaxValue );
        ShowDecimalFromOACurrency( long.MinValue );
        ShowDecimalFromOACurrency( 123456789L );
        ShowDecimalFromOACurrency( 1234567890000L );
        ShowDecimalFromOACurrency( 1234567890987654321 );
        ShowDecimalFromOACurrency( 4294967295L );
    }
}

/*
This example of the decimal.FromOACurrency( ) method generates
the following output. It displays the OLE Automation Currency
value as a long and the result as a decimal.

          OA Currency            Decimal Value
          -----------            -------------
                    0                        0
                    1                   0.0001
               100000                       10
         100000000000                 10000000
  1000000000000000000          100000000000000
  1000000000000000001     100000000000000.0001
  9223372036854775807     922337203685477.5807
 -9223372036854775808    -922337203685477.5808
            123456789               12345.6789
        1234567890000                123456789
  1234567890987654321     123456789098765.4321
           4294967295              429496.7295
*/

// Example of the decimal.FromOACurrency method. 
import System.*;

class DecimalFromOACurrencyDemo
{
    private static String dataFmt = "{0,21}{1,25}";

    // Display the decimal.FromOACurrency parameter and decimal result.
    public static void ShowDecimalFromOACurrency(long Argument)
    {
        System.Decimal decCurrency = System.Decimal.FromOACurrency(Argument);
        Console.WriteLine(dataFmt,System.Convert.ToString(Argument),
            decCurrency);
    } //ShowDecimalFromOACurrency

    public static void main(String[] args)
    {
        Console.WriteLine( "This example of the " 
            + "decimal.FromOACurrency( ) method generates \nthe " 
            + "following output. It displays the OLE Automation " 
            + "Currency \nvalue as a long and the result as a "
            + "decimal.\n" );
        Console.WriteLine( dataFmt, "OA Currency", "Decimal Value" );
        Console.WriteLine( dataFmt, "-----------", "-------------" );
        
        //Convert OLE Automation Currency values to decimal objects.
        ShowDecimalFromOACurrency( 0L );
        ShowDecimalFromOACurrency( 1L );
        ShowDecimalFromOACurrency( 100000L );
        ShowDecimalFromOACurrency( 100000000000L );
        ShowDecimalFromOACurrency( 1000000000000000000L );
        ShowDecimalFromOACurrency( 1000000000000000001L );
        ShowDecimalFromOACurrency( Long.MAX_VALUE );
        ShowDecimalFromOACurrency( Long.MIN_VALUE );
        ShowDecimalFromOACurrency( 123456789L );
        ShowDecimalFromOACurrency( 1234567890000L );
        ShowDecimalFromOACurrency( 1234567890987654321L );
        ShowDecimalFromOACurrency( 4294967295L );
    } //main
} //DecimalFromOACurrencyDemo

/*
This example of the decimal.FromOACurrency( ) method generates
the following output. It displays the OLE Automation Currency
value as a long and the result as a decimal.

          OA Currency            Decimal Value
          -----------            -------------
                    0                        0
                    1                   0.0001
               100000                       10
         100000000000                 10000000
  1000000000000000000          100000000000000
  1000000000000000001     100000000000000.0001
  9223372036854775807     922337203685477.5807
 -9223372036854775808    -922337203685477.5808
            123456789               12345.6789
        1234567890000                123456789
  1234567890987654321     123456789098765.4321
           4294967295              429496.7295
*/

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.