如何delphi button1用FormatdateTime取当前系统日期,然后按钮2实现日期递增?
用label显示日期,我按钮一代码:procedureTForm1.Button1Click(Sender:TObject);beginLabel1.Caption:=F...
用label显示日期,我按钮一代码:procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=FormatdateTime('dddddd ',now);
end;
按钮二如何写代码实现按钮一取出的日期递增 并显示在label上? 展开
begin
Label1.Caption:=FormatdateTime('dddddd ',now);
end;
按钮二如何写代码实现按钮一取出的日期递增 并显示在label上? 展开
2个回答
展开全部
uses DateUtils;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=FormatdateTime('dddddd ',now);
end;
procedure TForm1.Button2Click(Sender: TObject);
function Replace(astr: string):string;
begin
astr:= StringReplace(astr,'年','-',[rfReplaceAll]) ;
astr:= StringReplace(astr,'月','-',[rfReplaceAll]) ;
astr:= StringReplace(astr,'日','-',[rfReplaceAll]) ;
Result:= Copy(astr,1,Length(astr)-1);
end;
var
vstr: string;
begin
vstr:= Replace(trim(label1.caption));
Label1.Caption:=FormatdateTime('dddddd',incday( StrToDate(vstr), 1));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=FormatdateTime('dddddd ',now);
end;
procedure TForm1.Button2Click(Sender: TObject);
function Replace(astr: string):string;
begin
astr:= StringReplace(astr,'年','-',[rfReplaceAll]) ;
astr:= StringReplace(astr,'月','-',[rfReplaceAll]) ;
astr:= StringReplace(astr,'日','-',[rfReplaceAll]) ;
Result:= Copy(astr,1,Length(astr)-1);
end;
var
vstr: string;
begin
vstr:= Replace(trim(label1.caption));
Label1.Caption:=FormatdateTime('dddddd',incday( StrToDate(vstr), 1));
end;
更多追问追答
追问
能运行但是按钮2会出错,取出来的日期无效,因为按钮一日期格式有个星期几,如何修改?
追答
控制面板--->区域和语言
把长日期格式改为:yyyy'年'M'月'd'日'
展开全部
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=FormatdateTime('yyyy-mm-dd ',now);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Label1.Caption:=FormatdateTime('yyyy-mm-dd ',incday(strtodate(label1.caption), 1));
end;
begin
Label1.Caption:=FormatdateTime('yyyy-mm-dd ',now);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Label1.Caption:=FormatdateTime('yyyy-mm-dd ',incday(strtodate(label1.caption), 1));
end;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询