Z zhhc Unregistered / Unconfirmed GUEST, unregistred user! 2002-07-30 #4 procedure TForm1.Edit1Exit(Sender: TObject); var d:TDate; begin Try d:=StrToDate(Edit1.Text); Edit1.Text:=DateToStr(d); except showmessage('error'); Edit1.SetFocus; end; end;
procedure TForm1.Edit1Exit(Sender: TObject); var d:TDate; begin Try d:=StrToDate(Edit1.Text); Edit1.Text:=DateToStr(d); except showmessage('error'); Edit1.SetFocus; end; end;
田 田伯光 Unregistered / Unconfirmed GUEST, unregistred user! 2002-07-30 #5 TDateTimePicker好用 不过如果你一定要用TEdit那么可以这么写 TEdit.Exit Begin Try StrToDate( Edit.Text ); Edit.Text :=FormatDateTime('yyyymmdd',StrToDate( Edit.Text )); Except ShowMessage('输入错误!'); End; End;
TDateTimePicker好用 不过如果你一定要用TEdit那么可以这么写 TEdit.Exit Begin Try StrToDate( Edit.Text ); Edit.Text :=FormatDateTime('yyyymmdd',StrToDate( Edit.Text )); Except ShowMessage('输入错误!'); End; End;
S SevenOrient Unregistered / Unconfirmed GUEST, unregistred user! 2002-07-30 #7 用TMaskEdit吧。 属性:EditMask 1.!9999/99/99;1; 2.Character fro Blanks:" " 空格