EncodeDate (C++)
Description
This example uses three edit controls, a label, and a button on a form. When you click the button, the day, month, and year specified in the edit controls is stored in a TDateTime object. Then the TDateTime object is converted to a String that is displayed in the label.
Code
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TDateTime dt;
try
{
dt = EncodeDate((Word)StrToInt(Edit1->Text), (Word)StrToInt(Edit2->Text), (Word)StrToInt(Edit3->Text));
Label1->Caption = DateToStr(dt);
}
catch(...)
{
ShowMessage("Invalid day, month, or year.");
}
}
Uses
- System.SysUtils.EncodeDate ( fr | de | ja )
- System.SysUtils.DateToStr ( fr | de | ja )