aqConvert.VarToStr Method

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

Description

The VarToStr method converts the specified value to a string. The resulting value is formatted according to the current local settings. To apply custom formatting, use the aqString.Format, aqConvert.CurrencyToFormatStr or aqConvert.DateTimeToFormatStr methods.

Declaration

aqConvert.VarToStr(V)

V [in]    Required    Variant    
Result String

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

V

The value to be converted to a string.

Result Value

A string that represents the value.

If the value is an array, VarToStr returns a string with a comma-separated list of array elements.

If the value is a null value, VarToStr returns an empty string. In DelphiScript, VarToStr(nil) returns '0'.

Example

JavaScript, JScript

function VarToStrExample()
{
  Log.Message(aqConvert.VarToStr(1247));
  Log.Message(aqConvert.VarToStr(-3.52));
}

/*
Output in the test log:
1247
-3.52
*/

Python

def VarToStrExample():
  Log.Message(aqConvert.VarToStr(1247))
  Log.Message(aqConvert.VarToStr(-3.52))

# Output in the test log:
# 1247
# -3.52

VBScript

Sub VarToStrExample
  Call Log.Message(aqConvert.VarToStr(1247))
  Call Log.Message(aqConvert.VarToStr(-3.52))
End Sub

' Output in the test log:
' 1247
' -3.52

DelphiScript

function VarToStrExample;
begin
  Log.Message(aqConvert.VarToStr(1247));
  Log.Message(aqConvert.VarToStr(-3.52));
end;

{
Output in the test log:
1247
-3.52
}

C++Script, C#Script

function VarToStrExample()
{
  Log["Message"]( aqConvert["VarToStr"](1247) );
  Log["Message"]( aqConvert["VarToStr"](-3.52) );
}

/*
Output in the test log:
1247
-3.52
*/

See Also

VarToFloat Method
VarToBool Method
VarToInt Method
GetVarType Method

Highlight search results