【发布时间】:2019-09-06 14:37:25
【问题描述】:
这段代码有什么问题?我不明白,如果我删除“尝试”我的应用程序不会打开,如果不删除总是出现“需要登录”...
procedure TF_login.FormActivate(Sender: TObject);
var
Result: Integer;
TextFile: TStringList;
VarArquivo: string;
text: string;
dataI, dataF : string;
begin
TextFile := TStringList.Create;
VarArquivo := System.IOUtils.TPath.GetDocumentsPath + PathDelim + 'Limit.txt';
try
TextFile.LoadFromFile(VarArquivo);
text := TextFile.Text;
// ShowMessage(TextFile.Text); // there is the text
// ShowMessage(text); // there is the text
dataI := FormatDateTime('dd/mm/yyyy', Now);
dataF := FormatDateTime('dd/mm/yyyy', StrToDate(text));
Result := CompareDate(StrToDate(dataI), StrToDate(dataF));
ShowMessage(dataF +' data f');
ShowMessage(dataI +' data I');
if ( Result = LessThanValue ) then
begin
ShowMessage('data F low');
end
else
begin
ShowMessage('data F high');
F_inicio.Show;
end;
FreeAndNil(TextFile);
except on E:
Exception do ShowMessage('An error happened!' + sLineBreak + '[' +
E.ClassName + '] ' + E.Message);
end;
end;
错误:[EConvertError] '09/11/2019' 不是有效日期
要创建文件,我会这样做:
procedure TF_login.btn_entrarClick(Sender: TObject);
var
data : tdatetime;
Resposta, data_s: string;
begin
PathFile := System.IOUtils.TPath.GetDocumentsPath;
NameFile := 'Limit.txt';
data := Now; //data actual
data := IncMonth(data, 2);
data_s := FormatDateTime('dd/mm/yyyy', data);
TFile.WriteAllText(TPath.Combine(PathFile, NameFile), data_s );
F_inicio.Show;
end;
该文件存在,因为第一个(和第二个)ShowMessage(评论的内容)向我显示“09/11/19”,但第三个和第四个没有出现在我看来......
OBS:Delphi 10.3 (RIO),平台:Android
【问题讨论】:
-
评论不用于扩展讨论;这个对话是moved to chat。
-
使用调试器准确找出代码失败的地方。目前我们可以看到引发了一个异常,但是您将其连同它提供的所有信息一起吞下。
标签: delphi firemonkey