N
Converts a value to a number, dates to serial numbers, -true to 1, error to ErrorValue, anything else to 0 (zero).
Syntax
expression.N(arg1);
expression
- A variable that represents a ApiWorksheetFunction class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
arg1 | Required | ApiRange | ApiName | number | string | boolean | The value to be converted. The value can be a logical value, text, or number. |
Returns
number
Example
This example shows how to convert a value to a number, dates to serial numbers, true to 1, error to {@link global#ErrorValue ErrorValue}, anything else to 0 (zero).
- Code
- Result
// How to convert an object to a number.
// Use a function to get a number from any data type.
let worksheet = Api.GetActiveSheet();
let func = Api.GetWorksheetFunction();
worksheet.GetRange("A1").SetValue(func.N(false));