Página 1 de 1

Gerador de número aleatório em Delphi

Enviado: domingo mar 30, 2025 3:37 pm
por HenryPyday
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)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
public
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
Numero: Integer;
begin
Randomize;
Numero := Random(100); // número entre 0 e 99
Label1.Caption := 'Número gerado: ' + IntToStr(Numero);
end;

end.



==============================================================

https://www.nasciweb.com.br