Verificar ano bissexto em Delphi
Enviado: sexta mar 28, 2025 5:23 pm
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
EditAno: TEdit;
ButtonVerificar: TButton;
LabelResultado: TLabel;
Label1: TLabel;
procedure ButtonVerificarClick(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ButtonVerificarClick(Sender: TObject);
var
Ano: Integer;
begin
Ano := StrToInt(EditAno.Text);
if ((Ano mod 4 = 0) and (Ano mod 100 <> 0)) or (Ano mod 400 = 0) then
LabelResultado.Caption := IntToStr(Ano) + ' é um ano bissexto'
else
LabelResultado.Caption := IntToStr(Ano) + ' não é um ano bissexto';
end;
end.
================================================================
https://www.nasciweb.com.br
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
EditAno: TEdit;
ButtonVerificar: TButton;
LabelResultado: TLabel;
Label1: TLabel;
procedure ButtonVerificarClick(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ButtonVerificarClick(Sender: TObject);
var
Ano: Integer;
begin
Ano := StrToInt(EditAno.Text);
if ((Ano mod 4 = 0) and (Ano mod 100 <> 0)) or (Ano mod 400 = 0) then
LabelResultado.Caption := IntToStr(Ano) + ' é um ano bissexto'
else
LabelResultado.Caption := IntToStr(Ano) + ' não é um ano bissexto';
end;
end.
================================================================
https://www.nasciweb.com.br