【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.
联系客服