Delphi簡單判斷閏年,覺得代碼中更實用的是日期選擇器的使用,用來選擇年份的,直接調用Windows系統的日歷控件顯示日期,顯示後可通過按鈕控制閏年的判斷檢查。
01
unit
Unit1;
02
interface
03
uses
04
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
05
Dialogs, StdCtrls, ComCtrls;
06
type
07
TForm1 =
class
(TForm)
08
DateTimePicker1: TDateTimePicker;
09
Button1: TButton;
10
procedure
Button1Click(Sender: TObject);
11
private
12
{ Private declarations }
13
public
14
{ Public declarations }
15
end
;
16
var
17
Form1: TForm1;
18
implementation
19
{$R *.dfm}
20
TForm1
.
21
22
year,m,d :
Word
23
begin
24
decodedate(DateTimePicker1
Date,year,m,d);
25
if
(Year
mod
4
=
0
)
and
((Year
100
<>
or
400
))
then
26
showmessage(
'所選年份是閏年!'
27
else
28
'所選年份不是閏年!'
);
29
30
本例效果圖:代碼文件:unit Unit1;i
本例效果圖: 代碼文件:unit Unit1;inter
[概述] 自從上次發布了[DIOCP開源項目-利用隊列+0M
function CreateWaitable