Home  |  Delphi .net Home  |  System.Convert  |  ToDecimal Method
ToDecimal  
Method  
Converts data from one data type to a Decimal data type
Convert Class
System NameSpace
CF1.  Function ToDecimal ( Value : Boolean; ) : Decimal;
CF2.  Function ToDecimal ( Value : Byte; ) : Decimal;
CF3.  Function ToDecimal ( Value : Char; ) : Decimal;
CF4.  Function ToDecimal ( Value : DateTime; ) : Decimal;
CF5.  Function ToDecimal ( Value : SmallInt; ) : Decimal;
CF6.  Function ToDecimal ( Value : ShortInt; ) : Decimal;
CF7.  Function ToDecimal ( Value : Integer; ) : Decimal;
CF8.  Function ToDecimal ( Value : Int64; ) : Decimal;
CF9.  Function ToDecimal ( Value : UInt64; ) : Decimal;
CF10.  Function ToDecimal ( Value : Word; ) : Decimal;
CF11.  Function ToDecimal ( Value : Single; ) : Decimal;
CF12.  Function ToDecimal ( Value : Double; ) : Decimal;
CF13.  Function ToDecimal ( Value : Decimal; ) : Decimal;
CF14.  Function ToDecimal ( Value : Decimal; ) : Decimal;
CF15.  Function ToDecimal ( Value : String; ) : Decimal;
CF16.  Function ToDecimal ( Value:StringValue : String; FormatProvider : IFormatProvider; ) : Decimal;
CF17.  Function ToDecimal ( Value : Object; ) : Decimal;
CF18.  Function ToDecimal ( Value:ObjectValue : Object; FormatProvider : IFormatProvider; ) : Decimal; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Attempts to transfer the value from one of the given Value data types to Decimal.
 
The optional FormatProvider parameter determines the parsing rules and is beyond the scope of this article.
Notes
An exception is thrown if the conversion fails.
Microsoft MSDN Links
System
System.Convert
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  myDec : Decimal;
  myStr : String;

begin
  myStr  := '-123.456';

  myDec  := System.Convert.ToDecimal(myStr);

  Console.WriteLine(myDec.ToString);

  Console.ReadLine;
end.
Show full unit code
  -123.456
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author