次の方法で共有


Decimal.FromOACurrency メソッド

OLE オートメーション通貨値を格納している指定した 64 ビット符号付き整数を、それと等価の Decimal 値に変換します。

Public Shared Function FromOACurrency( _
   ByVal cy As Long _) As Decimal
[C#]
public static decimal FromOACurrency(longcy);
[C++]
public: static Decimal FromOACurrency(__int64cy);
[JScript]
public static function FromOACurrency(
   cy : long) : Decimal;

パラメータ

  • cy
    OLE オートメーション通貨値。

戻り値

cy と等価の値を格納している Decimal

使用例

[Visual Basic, C#, C++] FromOACurrency メソッドを使用して OLE オートメーション通貨値を含む Int64 フィールドを Decimal の等価の数値に変換するコード例を次に示します。

 
' Example of the Decimal.FromOACurrency method. 
Imports System
Imports Microsoft.VisualBasic

Module DecimalFromOACurrencyDemo
    
    Const dataFmt As String = "{0,21}{1,25}"

    ' Display the Decimal.FromOACurrency parameter and Decimal result.
    Sub ShowDecimalFromOACurrency( Argument As Long )

        Dim decCurrency As Decimal = _
            Decimal.FromOACurrency( Argument )

        Console.WriteLine( dataFmt, Argument, decCurrency )
    End Sub

    Sub Main( )
        Console.WriteLine( "This example of the " & _
            "Decimal.FromOACurrency( ) method generates " & vbCrLf & _
            "the following output. It displays the OLE Automation " & _
            "Currency " & vbCrLf & "value as a Long and the " & _
            "result as a Decimal." & vbCrLf )
        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 ) 
    End Sub
End Module 

' 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

[C#] 
// 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
*/

[C++] 
// Example of the Decimal::FromOACurrency method. 
#using <mscorlib.dll>
using namespace System;

const __wchar_t* dataFmt = L"{0,21}{1,25}";

// Display the Decimal::FromOACurrency parameter and Decimal result.
void ShowDecimalFromOACurrency( __int64 Argument )
{
    Decimal decCurrency = Decimal::FromOACurrency( Argument );

    Console::WriteLine( dataFmt, __box( Argument ), 
        __box( decCurrency ) );
}

void main( )
{
    Console::WriteLine( S"This example of the " 
        S"Decimal::FromOACurrency( ) method generates \nthe " 
        S"following output. It displays the OLE Automation " 
        S"Currency \nvalue as an __int64 and the result as a " 
        S"Decimal.\n" );
    Console::WriteLine( dataFmt, S"OA Currency", S"Decimal Value" );
    Console::WriteLine( dataFmt, S"-----------", S"-------------" );

    // Convert OLE Automation Currency values to Decimal objects.
    ShowDecimalFromOACurrency( 0L );
    ShowDecimalFromOACurrency( 1L );
    ShowDecimalFromOACurrency( 100000L );
    ShowDecimalFromOACurrency( 100000000000L );
    ShowDecimalFromOACurrency( 1000000000000000000L );
    ShowDecimalFromOACurrency( 1000000000000000001L );
    ShowDecimalFromOACurrency( Int64::MaxValue );
    ShowDecimalFromOACurrency( Int64::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 an __int64 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
*/

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

Decimal 構造体 | Decimal メンバ | System 名前空間 | ToOACurrency