Converts a numeric expression and it assigns the result to a text variable.  

Optional [addCommas] parameter when set to True will add commas to the integer portion of a large number.

 

Usually this is wanted when the results are to be used in a report where the number of decimal value must be controlled.  It will also provide comma separation for large numbers.

 

Syntax:

stringVariable = AsString( expression, [ decimals ], [addCommas] )

 

Parameter:

Description:

expression

Expression to convert

[ decimals ]

Optional number of decimals to display

[addCommas]

Optional True/False to include commas in the number

stringVariable

Expression converted to a character string.

 

Example:

'  -----------------------------------------------

VARIABLES: integerOne, integerTwo TYPE: INTEGER

 
integerOne = 123
integerTwo = 456
 
PRINT integerOne + integerTwo

PRINT AsString(integerOne) + AsString(integerTwo)

 

Result:

This prints "579"

This prints "123456"

 

'  -----------------------------------------------
VARIABLES: decimalNum TYPE: FLOATING
 
decimalNum = 1235687.14254
 
PRINT "No Commas in number: " + AsString(decimalNum, 2)
PRINT "Account Balance is " + AsString(decimalNum, 2, TRUE)

 

Result:

No Commas in number: 1235687.14

Account Balance is 1,235,687.14

 

'  -----------------------------------------------

VARIABLES: floatVar TYPE: FLOATING

floatVar = 123.456789

 

PRINT AsString( floatVar, 2 )
 

Result:

This prints "123.45"

 
'  -----------------------------------------------
VARIABLES: floatVar TYPE: FLOATING
floatVar = 123456.456789

 
PRINT AsString( floatVar, 2, true )

 

Result:

This prints "123,456.45"  

 

Links:

AsFloating, AsInteger, AsSeries, IsFloating, IsInteger, IsString

See Also:

 

 


Edit Time: 9/25/2017 09:09:58 AM


Topic ID#: 47

 

Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software