3.5.7.43 Value

Description

This function converts a string number to double. It is a more limited version of Origin C's atof() function and is provided for compatibility with Excel.

Syntax

double Value(string str$[, int decimal])

Parameters

str

is the string that you want to convert to double.

decimal

Optional. Determines whether to replace the decimal separator in the text string. If text str$ uses comma "," as the decimal separator and the current system uses period "." as decimal, set decimal to 1 to replace comma with period. Vice versa.

Return

Return the double value that has been converted to double. From Origin2019, percent is also supported.

Example

string str1$ = "+.50";
double dstr1 = Value(str1$);
dstr1 = ;//should be "0.5"
string str2$ = "50%";
double dstr2 = Value(str2$);
dstr2 = ;//should be "0.5"
value("2k")=;//2000
value("1,071")=;//1071
value("12,3", 1) =; //12.3