Applies to TestComplete 14.70, last modified on October 26, 2020

Description

The VarToInt method converts the variant value specified by the V parameter to an integer value.

Declaration

aqConvert.VarToInt(V)

V [in]    Required    Variant    
Result Integer

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

V

Specifies the variant value to be converted.

Result Value

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

Remarks

The VarToInt 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 following example demonstrates how you can convert variant values to integer values.

JavaScript, JScript

function VarToIntExample()
{

 // Converting strings to integer values
 Log.Message(aqConvert.VarToInt("1247"));
 Log.Message(aqConvert.VarToInt("-352"));
 
 // Converting hexadecimal numeric strings to integer values
 Log.Message(aqConvert.VarToInt("0x1A23"));
   
}

/*
The routine produces the following output:
1247
-352
6691
*/

Python

def VarToIntExample():
  # Converting strings to integer values
  Log.Message(aqConvert.VarToInt("1247"))
  Log.Message(aqConvert.VarToInt("-352"))
  # Converting hexadecimal numeric strings to integer values
  Log.Message(aqConvert.VarToInt("0x1A23"))

# The routine produces the following output:
# 1247
# -352
# 6691

VBScript

Sub VarToIntExample

 ' Converting strings to integer values
 Call Log.Message(aqConvert.VarToInt("1247"))
 Call Log.Message(aqConvert.VarToInt("-352"))
 
 ' Converting hexadecimal numeric strings to integer values
 Call Log.Message(aqConvert.VarToInt("&H1A23"))

End Sub

' The routine produces the following output:
' 1247
' -352
' 6691

DelphiScript

function VarToIntExample;
begin

 // Converting strings to integer values
 Log.Message(aqConvert.VarToInt('1247'));
 Log.Message(aqConvert.VarToInt('-352'));
 
 // Converting hexadecimal numeric strings to integer values
 Log.Message(aqConvert.VarToInt('$1A23'));

end;

{
The routine produces the following output:
1247
-352
6691
}

C++Script, C#Script

function VarToIntExample()
{

 // Converting strings to integer values
 Log["Message"]( aqConvert["VarToInt"]("1247") );
 Log["Message"]( aqConvert["VarToInt"]("-352") );
 
 // Converting hexadecimal numeric strings to integervalues
 Log["Message"]( aqConvert["VarToInt"]("0x1A23") );

}

/*
The routine produces the following output:
1247
-352
6691
*/

See Also

VarToFloat Method
VarToBool Method
VarToStr Method
GetVarType Method
VarClear Method

Highlight search results