Hide

SftMask/OCX 7.0 - ActiveX Masked Edit Control

Display
Print

FormatNumber Method, SftMaskCalculator Object

Converts a value into a displayable number.

Syntax

VB.NETobject.FormatNumber(ByVal Val As Double, ByVal FracDigits As Short, ByVal LeadZero As Short, ByVal Grouping As Short, ByVal DecimalSep As String, ByVal ThousandSep As String, ByVal NegativeOrder As Short, ByRef Text As String)
VBobject.FormatNumber(ByVal Val As Double, ByVal FracDigits As Integer, ByVal LeadZero As Integer, ByVal Grouping As Integer, ByVal DecimalSep As String, ByVal ThousandSep As String, ByVal NegativeOrder As Integer, Text As String)
C#.NETvoid object.FormatNumber(double Val, short FracDigits, short LeadZero, short Grouping, string DecimalSep, string ThousandSep, short NegativeOrder, out string Text);
VC++HRESULT object->FormatNumber(double Val, short FracDigits, short LeadZero, short Grouping, _bstr_t DecimalSep, _bstr_t ThousandSep, short NegativeOrder, _bstr_t* Text);
CHRESULT object->raw_FormatNumber(double Val, short FracDigits, short LeadZero, short Grouping, BSTR DecimalSep, BSTR ThousandSep, short NegativeOrder, BSTR* Text);

object

A SftMaskCalculator object.

Val

A Double. This value is formatted as a string using the provided attributes and returned in Text.

FracDigits

The number of desired fractional digits (0-99) or -1. If -1 is specified, the user locale is used (see GetLocaleInfo, LOCALE_IDIGITS).

LeadZero

1 if leading zeros are desired, otherwise 0. If -1 is specified, the user locale is used (see GetLocaleInfo, LOCALE_ILZERO).

Grouping

Specifies the size of each group of digits to the left of the decimal point (0-9). If -1 is specified, the user locale is used (see GetLocaleInfo, LOCALE_SGROUPING).

DecimalSep

The decimal separator string (up to four characters). If an empty string is specified, the user locale is used (see GetLocaleInfo, LOCALE_SDECIMAL).

ThousandSep

The thousands (group) separator string (up to four characters). If an empty string is specified, the user locale is used (see GetLocaleInfo, LOCALE_STHOUSAND).

NegativeOrder

The display mode for negative values (0-4). If -1 is specified, the user locale is used (see GetLocaleInfo, LOCALE_INEGNUMBER).

NegativeOrderExampleDescription
-1The user locale is used (see GetLocaleInfo, LOCALE_INEGNUMBER)
0(1.1)Left parenthesis, number, right parenthesis
1-1.1Negative sign, number
2- 1.1Negative sign, space, number
31.1-Number, negative sign
41.1 -Number, space, negative sign

Text

The formatted string is returned in the Text argument.

Comments

The FormatNumber method converts a value into a displayable number.

Calculator.FormatCurrency is used to format numbers with currency attributes.

Calculator.FormatNumberV is used for languages such as VBScript, which are limited by requiring Variant arguments and do not support strongly typed arguments for return values. For more information please see Using SftMask/OCX with Internet Explorer.

Examples

VB.NET

    MsgBox(Text)
    Text = "long"
    AxSftMask1.Calendar.FormatDate(#8/1/2000#, Text)
    MsgBox(Text)
    Text = "dddd, MMMM d 'in the year' yyyy"
    AxSftMask1.Calendar.FormatDate(#8/1/2000#, Text)
    MsgBox(Text)

    AxSftMask1.Calculator.FormatNumber(48533.85, -1, -1, -1, "", "", -1, FmtVal)
    MsgBox(FmtVal)

    Text = ""
    AxSftMask1.Calendar.FormatTime(#5:01:59 PM#, Text)
    MsgBox(Text)
    Text = "'Hour='H 'Mins='m 'Secs='s"
    AxSftMask1.Calendar.FormatTime(#5:01:59 PM#, Text)

VB6

    MsgBox (Text)
    Text = "long"
    SftMask1.Calendar.FormatDate #8/1/2000#, Text
    MsgBox (Text)
    Text = "dddd, MMMM d 'in the year' yyyy"
    SftMask1.Calendar.FormatDate #8/1/2000#, Text
    MsgBox (Text)

    SftMask1.Calculator.FormatNumber 48533.85, -1, -1, -1, "", "", -1, FmtVal
    MsgBox (FmtVal)

    Text = ""
    SftMask1.Calendar.FormatTime #5:01:59 PM#, Text
    MsgBox (Text)
    Text = "'Hour='H 'Mins='m 'Secs='s"
    SftMask1.Calendar.FormatTime #5:01:59 PM#, Text

C#

    MessageBox.Show(Text);
    Text = "long";
    axSftMask1.Calendar.FormatDate(new DateTime(2000, 8, 1), ref Text);
    MessageBox.Show(Text);
    Text = "dddd, MMMM d 'in the year' yyyy";
    axSftMask1.Calendar.FormatDate(new DateTime(2000, 8, 1), ref Text);
    MessageBox.Show(Text);

    axSftMask1.Calculator.FormatNumber(48533.85, -1, -1, -1, "", "", -1, out FmtVal);
    MessageBox.Show(FmtVal);

    Text = "";
    axSftMask1.Calendar.FormatTime(new DateTime(2000, 8, 1, 5, 1, 59), ref Text);
    MessageBox.Show(Text);
    Text = "'Hour='H 'Mins='m 'Secs='s";
    axSftMask1.Calendar.FormatTime(new DateTime(2000, 8, 1, 5, 1, 59), ref Text);

C++

    m_pMask1->Calendar->FormatDate(COleDateTime(2000, 8, 1, 0,0,0), &FmtVal);
    AfxMessageBox(CString(FmtVal));

    FmtVal = _T("dddd, MMMM d 'in the year' yyyy");
    m_pMask1->Calendar->FormatDate(COleDateTime(2000, 8, 1, 0,0,0), &FmtVal);
    AfxMessageBox(CString(FmtVal));


    m_pMask1->Calculator->FormatNumber(48533.85, -1, -1, -1, _bstr_t(_T("")), _bstr_t(_T("")), -1, &FmtVal);
    AfxMessageBox(CString(FmtVal));

    FmtVal = _T("");
    m_pMask1->Calendar->FormatTime(COleDateTime(2000, 8, 1, 5, 1, 59), &FmtVal);
    AfxMessageBox(CString(FmtVal));

    FmtVal = _T("'Hour='H 'Mins='m 'Secs='s");

See Also SftMaskCalculator Object | Object Hierarchy


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.