Applies to TestComplete 14.60, last modified on September 18, 2020

Description

The StrToCurrency method converts the string specified by the S parameter to a currency value.

Declaration

aqConvert.StrToCurrency(S)

S [in]    Required    String    
Result Currency

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

S

Specifies the string to be converted to a floating-point value. A valid string must consist of an optional sign (+ or -), a string of digits with an optional decimal point, and an optional mantissa. The mantissa consists of 'E' or 'e' followed by an optional sign (+ or -) and a whole number. Leading and trailing blanks are ignored.

Thousand separators and currency symbols are not allowed in the string. If the source string is invalid, StrToCurrency raises an exception.

Result Value

The currency value to which the specified string has been converted.

Example

The code below demonstrates how you can convert strings to currency values.

JavaScript, JScript

function StringToCur()
{
  Log.Message(aqConvert.StrToCurrency("14535.47"));
  Log.Message(aqConvert.StrToCurrency("$1,453,255"));
}

/*
The routine produces the following output for the English locale:
14535.47
1453255.00
*/

Python

def StringToCur():
  Log.Message(aqConvert.StrToCurrency("14535.47"))
  Log.Message(aqConvert.StrToCurrency("$1,453,255"))

# The routine produces the following output for the English locale:
# 14535.47
# 1453255.00

VBScript

Sub StringToCur
  Log.Message(aqConvert.StrToCurrency("14535.47"))
  Log.Message(aqConvert.StrToCurrency("$1,453,255"))
end Sub

'The routine produces the following output for the English locale:
' 14535.47
' 1453255.00

DelphiScript

procedure StringToCur;
begin 
  Log.Message(aqConvert.StrToCurrency('14535.47'));
  Log.Message(aqConvert.StrToCurrency('$1,453,255'));
end;

{
The routine produces the following output for the English locale:
14535.47
1453255.00
}

C++Script, C#Script

function StringToCur()
{
  Log["Message"](aqConvert["StrToCurrency"]("14535.47"));
  Log["Message"](aqConvert["StrToCurrency"]("$1,453,255"));
}

/*
The routine produces the following output for the English locale:
14535.47
1453255.00
*/

See Also

Working With Numeric Values
StrToFloat Method
CurrencyToStr Method
CurrencyToFormatStr Method
Format Method

Highlight search results