Convert.ToDecimal(Convert)

Converts data to a Decimal number.

Applies To

Description

Converts data to a Decimal number. This converts data types into numbers. Not all objects will return a non-zero number when converting to decimal.

  • Text: any text that resembles a number will resolve into a number. If the text contains non-numeric characters, then the text will be converted to zero.

  • Booleans: true resolves to one, and false resolves to zero.

  • Arrays, and Objects: will evaluate to zero.

Properties and Methods

None

Available

The .ToDecimal(Convert) method is available in:

  • 15.03.016

  • All newer builds

Type

Decimal

Syntax

Convert.ToDecimal(Convert);

Parameters

Parameter

Required

Description

Convert Yes Any data type and value that converts to a number

Example

Event.Form.MessageBox('Text: ' + Convert.ToDecimal('25.34') +

'\nNon-numeric text: ' + Convert.ToDecimal('1.23 Hello') +

'\nInteger: ' + Convert.ToDecimal(12) +

'\nDateTime: ' + Convert.ToDecimal(DateTime.Now) +

'\nBoolean: ' + Convert.ToDecimal(true) +

'\nArray: ' + Convert.ToDecimal([1, 2, 3]) +

'\nObject: ' + Convert.ToDecimal({}));

 

/*Expected System Prompt Display

Text: 25.34

Non-numeric text: 0

Integer: 12

DateTime: 0

Boolean: 1

Array: 0

Object: 0

*/