aqConvert.StrToInt Method

Applies to TestComplete 14.40, last modified on April 22, 2021

Description

The StrToInt method converts the string S, which represents an integer number in decimal notation, to a number.

Declaration

aqConvert.StrToInt(S)

S [in]    Required    String    
Result Integer

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 number. If the source string does not represent a valid number, StrToInt raises an exception.

Result Value

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

Remarks

The StrToInt method can convert strings of hexadecimal characters that are prefixed with the following symbols:

Your project's language Symbol
JavaScript, JScript, Python, C#Script and C++Script 0x
VBScript &H
DelphiScript $

Example

The code below demonstrates how you can convert strings to integer numbers.

JavaScript, JScript

function StringToIntNum()
{
  Log.Message(aqConvert.StrToInt("153"));
  Log.Message(aqConvert.StrToInt("0x123"));
}

/*
The routine produces the following output:
153
9111111111111111111
291
*/

Python

def StringToIntNum():
  Log.Message(aqConvert.StrToInt("153"))
  Log.Message(aqConvert.StrToInt("0x123"))

# The routine produces the following output:
# 153
# 9111111111111111111
# 291

VBScript

sub StringToIntNum
  Log.Message(aqConvert.StrToInt("153"))
  Log.Message(aqConvert.StrToInt("&H123"))
end sub

'The routine produces the following output:
'153
'9111111111111111111
'291

DelphiScript

procedure StringToIntNum;
begin 
  Log.Message(aqConvert.StrToInt('153'));
  Log.Message(aqConvert.StrToInt('$123'));
end;

{
The routine produces the following output:
153
9.111111111111111111E18
291
}

C++Script, C#Script

function StringToIntNum()
{
  Log["Message"](aqConvert["StrToInt"]("153"));
  Log["Message"](aqConvert["StrToInt"]("0x123"));
}

/*
The routine produces the following output:

153
9111111111111111111
291
*/

See Also

Working With Numeric Values
IntToStr Method
FloatToStr Method
CurrencyToStr Method
Format Method

Highlight search results