输入 年,月,显示当月的天数

unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

function GetDays(Year,Mouth: integer): integer;
begin
  case Mouth of
    1,3,5,7,8,10,12 : Result := 31;
    4,6,9,11 : Result :=30;
    2:begin
        if isleapYear(Year) then
        begin
          Result :=29;
        end else
        begin
          Result :=28;
        end;
      end else
    Result := 0;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit3.Text := IntToStr(GetDays(StrToInt(Edit1.text),StrToInt(Edit2.text)));
end;

end.

原文地址:https://www.cnblogs.com/beeone/p/1800411.html