Hide

SftMask/OCX 7.0 - ActiveX Masked Edit Control

Display
Print

Fmt1 Sample (C#)

This sample illustrates date, time and number formatting.

This is not an executable sample, so a complete project is not provided. These statements are intended to show basic concepts and the syntax used.

private void Form1_Load(object sender, System.EventArgs e)
{
    string FmtVal;
    axSftMask1.Calculator.FormatCurrency(48533.85, -1, -1, -1, "", "", -1, -1, "", out FmtVal);
    MessageBox.Show(FmtVal);

    string Text;
    Text = "short";
    axSftMask1.Calendar.FormatDate(new DateTime(2000, 8, 1), ref Text);
    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);
    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);
    MessageBox.Show("Year=" + Year.ToString() + " Month=" + Month.ToString() + " Day=" + Day.ToString() + " DayOfWeek=" + DayOfWeek.ToString());

    short Hours, Minutes, Seconds;
    axSftMask1.Calendar.GetTimeInfo(new DateTime(2006, 7, 14, 5, 49, 23), out Hours, out Minutes, out Seconds);
    MessageBox.Show("Hours=" + Hours.ToString() + " Minutes=" + Minutes.ToString() + " Seconds=" + Seconds.ToString());
}

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