本文整理匯總了VB.NET中System.Decimal.ToOACurrency方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Decimal.ToOACurrency方法的具體用法?VB.NET Decimal.ToOACurrency怎麽用?VB.NET Decimal.ToOACurrency使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Decimal
的用法示例。
在下文中一共展示了Decimal.ToOACurrency方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: DecimalToOACurrencyDemo
' Example of the Decimal.ToOACurrency method.
Module DecimalToOACurrencyDemo
Const dataFmt As String = "{0,31}{1,27}"
' Get the exception type name; remove the namespace prefix.
Function GetExceptionType( ex As Exception ) As String
Dim exceptionType As String = ex.GetType( ).ToString( )
Return exceptionType.Substring( _
exceptionType.LastIndexOf( "."c ) + 1 )
End Function
' Display the Decimal.ToOACurrency parameter and the result
' or exception.
Sub ShowDecimalToOACurrency( Argument As Decimal )
' Catch the exception if ToOACurrency( ) throws one.
Try
Dim oaCurrency As Long = Decimal.ToOACurrency( Argument )
Console.WriteLine( dataFmt, Argument, _
oaCurrency )
Catch ex As Exception
Console.WriteLine( dataFmt, Argument, _
GetExceptionType( ex ) )
End Try
End Sub
Sub Main( )
Console.WriteLine( "This example of the " & _
"Decimal.ToOACurrency( ) method generates " & vbCrLf & _
"the following output. It displays the argument as " & _
"a Decimal " & vbCrLf & "and the OLE Automation " & _
"Currency value as a Long." & vbCrLf )
Console.WriteLine( dataFmt, "Argument", _
"OA Currency or Exception" )
Console.WriteLine( dataFmt, "--------", _
"------------------------" )
' Convert Decimal values to OLE Automation Currency values.
ShowDecimalToOACurrency( 0D )
ShowDecimalToOACurrency( 1D )
ShowDecimalToOACurrency( _
Decimal.Parse( "1.0000000000000000000000000000" ) )
ShowDecimalToOACurrency( 100000000000000D )
ShowDecimalToOACurrency( _
Decimal.Parse( "100000000000000.00000000000000" ) )
ShowDecimalToOACurrency( 10000000000000000000000000000D )
ShowDecimalToOACurrency( 0.000000000123456789D )
ShowDecimalToOACurrency( 0.123456789D )
ShowDecimalToOACurrency( 123456789D )
ShowDecimalToOACurrency( 123456789000000000D )
ShowDecimalToOACurrency( 4294967295D )
ShowDecimalToOACurrency( 18446744073709551615D )
ShowDecimalToOACurrency( -79.228162514264337593543950335D )
ShowDecimalToOACurrency( -79228162514264.337593543950335D )
End Sub
End Module
' This example of the Decimal.ToOACurrency( ) method generates
' the following output. It displays the argument as a Decimal
' and the OLE Automation Currency value as a Long.
'
' Argument OA Currency or Exception
' -------- ------------------------
' 0 0
' 1 10000
' 1.0000000000000000000000000000 10000
' 100000000000000 1000000000000000000
' 100000000000000.00000000000000 1000000000000000000
' 10000000000000000000000000000 OverflowException
' 0.000000000123456789 0
' 0.123456789 1235
' 123456789 1234567890000
' 123456789000000000 OverflowException
' 4294967295 42949672950000
' 18446744073709551615 OverflowException
' -79.228162514264337593543950335 -792282
' -79228162514264.337593543950335 -792281625142643376