aqConvert.VarToFloat Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The VarToFloat method converts the variant value specified by the V parameter to a floating-point value.

Declaration

aqConvert.VarToFloat(V)

V [in]    Required    Variant    
Result Double

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 floating-point value to which the specified variant value has been converted.

Example

The following example demonstrates how you can convert variant values to float values.

JavaScript, JScript

function VarToFloatExample()
{

 // Converting strings to float values
 Log.Message(aqConvert.VarToFloat("12.47"));
 Log.Message(aqConvert.VarToFloat("-3.52"));
 Log.Message(aqConvert.VarToFloat("128"));

}

/*
The routine produces the following output:
12.47
-3.52
128
*/

Python

def VarToFloatExample():
  # Converting strings to float values
  Log.Message(aqConvert.VarToFloat("12.47"))
  Log.Message(aqConvert.VarToFloat("-3.52"))
  Log.Message(aqConvert.VarToFloat("128"))

# The routine produces the following output:
# 12.47
# -3.52
# 128

VBScript

Sub VarToFloatExample

 ' Converting strings to float values
 Call Log.Message(aqConvert.VarToFloat("12.47"))
 Call Log.Message(aqConvert.VarToFloat("-3.52"))
 Call Log.Message(aqConvert.VarToFloat("128"))

End Sub

' The routine produces the following output:
' 12.47
' -3.52
' 128

DelphiScript

function VarToFloatExample;
begin

 // Converting strings to float values
 Log.Message(aqConvert.VarToFloat('12.47'));
 Log.Message(aqConvert.VarToFloat('-3.52'));
 Log.Message(aqConvert.VarToFloat('128'));

end;

{
The routine produces the following output:
12.47
-3.52
128
}

C++Script, C#Script

function VarToFloatExample()
{

 // Converting strings to float values
 Log["Message"]( aqConvert["VarToFloat"]("12.47") );
 Log["Message"]( aqConvert["VarToFloat"]("-3.52") );
 Log["Message"]( aqConvert["VarToFloat"]("128") );

}

/*
The routine produces the following output:
12.47
-3.52
128
*/

See Also

VarToInt Method
VarToBool Method
VarToStr Method
GetVarType Method
VarClear Method

Highlight search results