Try Catch

http://www.delphibasics.co.uk/RTL.asp?Name=try常用記錄

trans := TStringList.Create;  
try

except on ex: Exception do
    begin
        trans.Add(ex.Message) ;
         if not DirectoryExists(ExtractFilePath(Application.ExeName)+'error_log\') then
         CreateDir(ExtractFilePath(Application.ExeName)+'error_log\');
        trans.SaveToFile(ExtractFilePath(Application.ExeName)+'error_log\'+formatdatetime('yyyymmddhhnnss',now)+'.txt');
        messageDlg('資料發生錯誤,請洽系統人員', mtError, [mbOk], 0);
    end;

end;

參考http://www.delphibasics.co.uk/RTL.asp?Name=try

 

 

 

 

大家一起加入blogads 賺零用錢!!