• 时间计数器



    { 1 h=1*60 m=1*60*60 s=1*60*60*1000 hs=3600000hs}
    function StartCount():string;
    {$j+}
    const
          h:Integer=0;
          m:Integer=0;
          s:integer=0;
    {$j-}
    begin
      inc(s);
      if s>=60 then
      begin
        Inc(m);
        s:=0;
      end;
      if m>=60 then
      begin
        Inc(h);
        m:=0;
      end;
      Result:=Format('%.2d:%.2d:%.2d',[h,m,s]);
    end;

    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
    label1.Caption:= StartCount();
    end;
     
    ///倒计时
     
    function dec1():string;
    {$j+}
    const i:Integer=60*5;
    {$j-}
    begin
       Dec(i);
       Result:=Format('剩余时间:%d',[i]);
    end;

    procedure TForm1.Timer1Timer(Sender: TObject);{$j+}
    begin
         label1.Caption:=dec1;
    end;


    var
      h1: Integer = 0;
      m1: Integer = 0;
      s1: Integer = 0;

    procedure TForm2.Timer1Timer(Sender: TObject);
    begin
      if (h1 <= 0) and (m1 <= 0) and (s1 <= 0) then
        exit;

      Dec(s1);
      if s1 <= 0 then
      begin
        if (m1 > 0) or (h1 > 0) then
        begin
          Dec(m1);
          s1 := 60;
        end;
      end;
      if m1 < 0 then
      begin
        if h1 > 0 then
        begin
          Dec(h1);
          m1 := 60;
        end;
      end;

      Label1.Caption := Format('%.2d:%.2d:%.2d', [h1, m1, s1]);
    end;




  • 相关阅读:
    Restful 的概念预览
    Bootstrap中alerts的用法
    Bootstrap HTML编码规范总结
    Bootstrap中img-circle glyphicon及js引入加载更快的存放位置
    PI数据库
    memcached
    Bootstrap中样式Jumbotron,row, table的实例应用
    js事件监听
    jquery显示隐藏操作
    HDU4521+线段树+dp
  • 原文地址:https://www.cnblogs.com/xe2011/p/3875874.html
Copyright © 2020-2023  润新知