用delphi将文本文档读取出来赋值给string
如题,将保存在文档里的日期时间信息读取出来,赋值给string,然后转换成tdatetime,再赋值给tdatetime型变量。由timer判断,触发其他事件。...
如题,将保存在文档里的日期时间信息读取出来,赋值给string,然后转换成tdatetime,再赋值给tdatetime型变量。由timer判断,触发其他事件。
展开
1个回答
展开全部
procedure SaveDataTime(ATime: TDataTime; FileName: string);
var
slTmp: TStringList;
begin
slTmp := TStringList.Create;
try
DeleteFile(FileName);
slTmp.Add(DateTimeToStr(ATime));
slTmp.SaveToFile(AFileName);
finally
slTmp.Free;
end;
end;
procedure LoadDataTime(var ATime: TDataTime; FileName: string);
var
slTmp: TStringList;
begin
slTmp := TStringList.Create;
try
slTmp.LoadFromFile(AFileName);
if slTmp.Count > 0 then
ATime := StrToDateTime(slTmp[0]);
finally
slTmp.Free;
end;
end;
var
slTmp: TStringList;
begin
slTmp := TStringList.Create;
try
DeleteFile(FileName);
slTmp.Add(DateTimeToStr(ATime));
slTmp.SaveToFile(AFileName);
finally
slTmp.Free;
end;
end;
procedure LoadDataTime(var ATime: TDataTime; FileName: string);
var
slTmp: TStringList;
begin
slTmp := TStringList.Create;
try
slTmp.LoadFromFile(AFileName);
if slTmp.Count > 0 then
ATime := StrToDateTime(slTmp[0]);
finally
slTmp.Free;
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询