Hide

SftMask/OCX 7.0 - ActiveX Masked Edit Control

Display
Print

FormatTime Method, SftMaskCalendar Object

Converts a time into a displayable string.

Syntax

VB.NETobject.FormatTime(ByVal Dt As Date, ByRef Text As String)
VBobject.FormatTime(ByVal Dt As Date, Text As String)
C#.NETvoid object.FormatTime(System.DateTime Dt, ref string Text);
VC++HRESULT object->FormatTime(DATE Dt, _bstr_t* Text);
CHRESULT object->raw_FormatTime(DATE Dt, BSTR* Text);

object

A SftMaskCalendar object.

Dt

The time to be converted to a string. The converted time is returned in the Text argument.

Text

Defines the desired formatting for the specified Time Dt and returns the converted time as a string. If an empty string is specified, the time is formatted using the default user locale.

Comments

The FormatTime method converts a time into a displayable string.

The FormatTime method uses the Windows GetTimeFormat API to format the specified time Dt.

Text can be defined as an empty string or can consist of one or more of the following items:

TextDescription
hHours without leading zero for single-digit hours - 12-hour clock
hhHours with leading zero for single-digit hours - 12-hour clock
HHours without leading zero for single-digit hours - 24-hour clock
HHHours with leading zero for single-digit hours - 24-hour clock
mMinutes without leading zero for single-digit minutes
mmMinutes with leading zero for single-digit minutes
sSeconds without leading zero for single-digit seconds
ssSeconds with leading zero for single-digit seconds
tOne character time-marker string, such as A or P.
ttFull length, multicharacter time-marker string, such as AM or PM

Literal characters must be enclosed by single quotes.

Text = "hh':'mm':'ss tt"

To specify a literal single quote, use two quotes.

Calendar.FormatTimeV 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

    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)
    MsgBox(Text)

    Dim Year As Integer, Month As Integer, Day As Integer, DayOfWeek As Integer
    AxSftMask1.Calendar.GetDateInfo(#7/14/2006 5:49:23 PM#, Year, Month, Day, DayOfWeek)

VB6

    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
    MsgBox (Text)

    Dim Year As Integer, Month As Integer, Day As Integer, DayOfWeek As Integer
    SftMask1.Calendar.GetDateInfo #7/14/2006 5:49:23 PM#, Year, Month, Day, DayOfWeek

C#

    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);
    MessageBox.Show(Text);

    short Year, Month, Day, DayOfWeek;
    axSftMask1.Calendar.GetDateInfo(new DateTime(2006, 7, 14, 5, 49, 23), out Year, out Month, out Day, out DayOfWeek);

C++

    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");
    m_pMask1->Calendar->FormatTime(COleDateTime(2000, 8, 1, 5, 1, 59), &FmtVal);
    AfxMessageBox(CString(FmtVal));

    short Year, Month, Day, DayOfWeek;

See Also SftMaskCalendar Object | Object Hierarchy


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