Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Format numeric data according to instructions contained in a format expression.

 

Syntax

 

s = FORMAT$(NumericExpression [, [NumberOfDigits | FormatString]])

 

 

Returns

 

String

 

Parameters

 

Name

Type

Optional

Meaning

NumericExpression

Numeric

No

Number to be formatted

NumberOfDigits

Numeric

Yes

The maximum number of significant digits in range of 1 to 18. If not specified a default 16 will be used

FormatString

String

Yes

Format characters that will determine how the numeric expression should be formatted. There may be up to 18 digit-formatting digits on either side of the decimal point.  The mask may not contain literal characters unless each character is preceded with a backslash (\) escape character, or the literal characters are enclosed in quotes.

 

FormatString may contain one, two or three formatting masks, separated by semicolon (;) characters:

 

One mask

If FormatString contains just one format mask, the mask is used to format all possible values of num_expression.

For example: s = FORMAT$(z, "000.00")

 

Two masks

If FormatString contains two format masks, the first mask is used for positive values (=> 0), and the second mask is used for negative values (< 0).

For example: s = FORMAT$(-100, "+00000.00;-000")

 

Three masks

If FormatString contains three masks, the first mask is used for positive values (> 0), the second mask for negative values (< 0), and the third mask is used if num_expression is zero (0).

For example:

For y = -0.5 To 0.5 Step 0.5

  s = FORMAT$(y, "+.0;-.0; .0")

Next

 

Digit placeholders in a mask do not have to be contiguous. This allows you to format a single number into multiple displayed parts.

For example: s = FORMAT$(123456, "00\:00\:00")   '---12:34:56

 

 

Remarks

 

Restrictions

 

See also

 

String Handling,

 

Examples

 

 

 

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software