打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
【delphi】日期计算器

【delphi】日期计算器源码+exe文件 下载地址:http://www.wesoho.com/soft/down/DateTimeCal.rar

作者:扬帆 http://www.wesoho.com 转载请保留版权

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, WinSkinData, StdCtrls, DateUtils;

type
  TForm1 = class(TForm)
    SkinData1: TSkinData;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    Label1: TLabel;
    Label2: TLabel;
    Edit3: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
begin
  Edit1.Text := DateTimeToStr(Now());
end;

procedure TForm1.Button1Click(Sender: TObject);
var hh, mm, ss: Integer;
  newdate: TDateTime;
  ACount: Integer;
  AStrings: TStringList;
begin
  hh := 0;
  mm := 0;
  ss := 0;

  if ((Trim(Edit1.Text) = '') or (Trim(Edit2.Text) = '')) then
    Application.MessageBox('??ê?è?ê±??oí???ó?μ', 'ìáê?', MB_OK + MB_ICONINFORMATION)
  else
  begin
    AStrings := TStringList.Create;
    try
      ACount := ExtractStrings([':'], [' '], PChar(Trim(Edit2.Text)), AStrings);
      case ACount of
        0: begin
            Application.MessageBox('???ì2éê?è?μ????ó?μ', 'ìáê?', MB_OK + MB_ICONINFORMATION);
            Exit;
          end;
        1: begin
            Application.MessageBox('???ì2éê?è?μ????ó?μ', 'ìáê?', MB_OK + MB_ICONINFORMATION);
            Exit;
          end;
        2: begin
            mm := StrToInt(AStrings.Strings[0]);
            ss := StrToInt(AStrings.Strings[1]);
          end;

        3: begin
            hh := StrToInt(AStrings.Strings[0]);
            mm := StrToInt(AStrings.Strings[1]);
            ss := StrToInt(AStrings.Strings[2]);
          end;
      end;

      newdate := StrToDateTime(Edit1.Text);
      if RadioButton1.Checked then
      begin
        newdate := IncHour(newdate, hh);
        newdate := IncMinute(newdate, mm);
        newdate := IncSecond(newdate, ss);
      end
      else
      begin
        newdate := IncHour(newdate, -hh);
        newdate := IncMinute(newdate, -mm);
        newdate := IncSecond(newdate, -ss);
      end;
      Edit3.Text := DateTimeToStr(newdate);
    finally
      AStrings.Free;
    end;
  end;
end;

end.

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
DBGrid 分頁
Delphi 动态内存查找法
如何在有类型文件中添加数据(急用) (20分)
DELPHI中鼠标的各种操作
Delphi 7 中的随机函数
How to catch "MOUSE CLICK" in any place on screen ( OUT or IN form application)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服