T timelyraining Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-05 #1 如何判断edit.text是不是能转化成时间格式。 例如:2002-2-12 判断结果 是 啊啊啊 判断结果 否 如何实现????
老 老赵 Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-05 #2 procedure TForm1.Button1Click(Sender: TObject); var Da:TDatetime; begin try Da:=strtodatetime(edit1.text); except showmessage(edit1.text+' 错了!'); edit1.setfocus; exit; end; end;
procedure TForm1.Button1Click(Sender: TObject); var Da:TDatetime; begin try Da:=strtodatetime(edit1.text); except showmessage(edit1.text+' 错了!'); edit1.setfocus; exit; end; end;
Y yinhucn Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-05 #4 这样也行!大同小异! procedure TForm1.Button1Click(Sender: TObject); var dd:TDatetime; begin if TryStrToDate(Edit1.Text,dd) then ShowMessage('ok') else ShowMessage('error'); end;
这样也行!大同小异! procedure TForm1.Button1Click(Sender: TObject); var dd:TDatetime; begin if TryStrToDate(Edit1.Text,dd) then ShowMessage('ok') else ShowMessage('error'); end;
I ildg Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-05 #6 delphi6里面新增了一个函数叫tryxxxxx, 我忘了,原理和上面的同学说的一样, 只要这样就可以了