{主窗口單元}
unit Main;
interface
uses
……{略去其他內容}
procedure Table1BirthdayGetText(Sender: TField;
var Text: String;DisplayText: Boolean);
procedure Table1BirthdaySetText(Sender: TField;
const Text: String);
private
{ Private declarations }
public
{ Public declarations }
……{略}
implementation
{將自定義的單元包含進來}
uses DBDateEditMaskTrans;
{$R *.DFM}
……{其他過程略}
procedure TForm1.FormActivate(Sender: TObject);
{設置一個日期型字段的輸入掩碼,
可以放到TField字段定義中。}
begin
Table1.FieldByName(Birthday).EditMask:=
9999年99月99日;1;_;
end;
procedure TForm1.Table1BirthdayGetText(Sender:
TField; var Text: String;DisplayText: Boolean);
begin
DateFieldGetText(Sender,Text);
end;
procedure TForm1.Table1BirthdaySetText(Sender:
TField; const Text: String);
begin
if DateFieldSetText(Sender,Text)=False then
Abort; {轉換不成功,日期非法}
end;
end.