FormatNumberToText2

Takes a number and returns it as a String, with the option to remove trailing zeroes. FormatNumberToText2 scales the number and puts a fixed number of digits to the right of the decimal point, adding or removing digits as needed. The method also returns the number of decimal places and the scaling applied to the formatted number.

By default, FormatNumberToText2 formats the returned number as follows:

FormatNumberToText2 also enables you to override this default formatting.

Syntax

<HsvData>.FormatNumberToText2(lEntity, lParent, lValue, lAccount, dNumber, lStatus, vbUseDefaultNumDecimals, sAlternateNumDecimals, vbUseDefaultScale, sAlternateScale, vbUseTheUsersFormattingParameters, vbRemoveTrailingZeros, nNumDecimals, nScale)

Argument

Description

lEntity

Long (ByVal). If the lValue argument specifies the <Entity Currency>, <Entity Curr Adjs>, or <Entity Curr Total> Value dimension member, FormatNumberToText2 scales the return value by using the Scale attribute of the entity’s default currency.

Otherwise, you must pass in a valid Entity dimension member ID, but the scaling is determined by the lParent or lValue argument.

lParent

Long (ByVal). The member ID of the parent of the Entity dimension member identified by the lEntity argument. If the lValue argument specifies the <Parent Currency>, <Parent Curr Adjs>, or <Parent Curr Total> Value dimension member, FormatNumberToText2 scales the return value by using the Scale attribute of this parent entity’s default currency.

Otherwise, you must pass in a valid Entity dimension member ID, but the scaling is determined by the lEntity or lValue argument.

lValue

Long (ByVal). The member ID of the Value dimension member for the currency whose Scale attribute is to be applied to the return value.

If you pass the member ID of the <Entity Currency>, <Entity Curr Adjs>, <Entity Curr Total>, <Parent Currency>, <Parent Curr Adjs>, or <Parent Curr Total> Value dimension member, the scaling is determined by the lEntity and lParent arguments as described above.

lAccount

Long (ByVal). The member ID of the Account dimension member whose NumDecimalPlaces attribute is to be applied to the return value.

dNumber

Double (ByVal). The number to be converted and formatted.

lStatus

Long (ByVal). The cell status; the status determines whether a 0 passed to the dNumber argument is returned as the string 0 or as the string NoData. The following list provides guidelines for this argument:

  • If you pass cell data returned by another method to the dNumber argument, it is recommended that you also pass the status returned by that method to the lStatus argument.

  • If you want to format a number that is not returned from a cell, pass 0.

    Caution!

    If you pass cell data to dNumber but also pass a manually-specified status to lStatus, a security breach may occur. This could occur if the cell’s status indicates that the user does not have read access but you pass in 0 instead of the status.

vbUseDefaultNumDecimals

Boolean (ByVal). Specify TRUE to apply the NumDecimalPlaces attribute of the account identified by the lAccount argument, otherwise FALSE. If you specify FALSE, the number of decimal places is determined by the sAlternateNumDecimals argument.

sAlternateNumDecimals

Integer (ByVal). If you set the vbUseDefaultNumDecimals argument to FALSE, this argument specifies the number of decimal places to be applied to the return value.

To use the application’s default number of decimals, pass the HFMConstants type library constant DEFAULT_NUM_DECIMALS, described in Number Defaults Constants.

If you set the vbUseDefaultNumDecimals argument to TRUE, this argument is ignored.

vbUseDefaultScale

Boolean (ByVal). Specify TRUE to apply the Scale attribute of the currency identified by the lValue argument, otherwise FALSE. If you specify FALSE, the sAlternateScale argument specifies the scaling to be applied.

sAlternateScale

Integer (ByVal). If you set the vbUseDefaultScale argument to FALSE, this argument indicates the degree of scaling to apply to the return value. To leave the return value unscaled, pass 0. To scale the return value, each whole-number increment over 0 scales by a tenth. In other words, passing 1 scales by a tenth, passing 2 scales by a hundredth, and so on.

To use the application’s default scaling, pass the HFMConstants type library constant DEFAULT_SCALE, described in Number Defaults Constants.

If you set the vbUseDefaultScale argument to TRUE, this argument is ignored.

vbUseTheUsersFormatting Parameters

Boolean (ByVal). Determines whether the user’s preferred decimal and thousands separator characters should be applied to the return value. Pass TRUE to apply the user’s preferred characters, FALSE to apply the system defaults.

vbRemoveTrailingZeros

Boolean (ByVal). A flag that specifies whether to remove trailing zeroes. Pass TRUE to remove trailing zeroes, FALSE otherwise.

nNumDecimals

Integer. Returns the number of decimal places applied to the return value.

nScale

Integer. Returns the degree of scaling applied to the return value.

Return Value

String. The String equivalent of the number passed as the dNumber argument, formatted as specified by the arguments.