Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit unit_sorteio;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, Spin, Grids, XPMan, ExtCtrls;
- type
- Tfrm_sorteador_tuneup = class(TForm)
- btn_sort: TButton;
- Label2: TLabel;
- Label3: TLabel;
- spin_max: TSpinEdit;
- XPManifest1: TXPManifest;
- label_sort1: TLabel;
- label_sort2: TLabel;
- Image1: TImage;
- Label1: TLabel;
- procedure btn_sortClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frm_sorteador_tuneup: Tfrm_sorteador_tuneup;
- implementation
- uses Math;
- {$R *.dfm}
- procedure Tfrm_sorteador_tuneup.btn_sortClick(Sender: TObject);
- //VARIAVEIS LOCAIS
- var max: Integer;
- var res1: String;
- var res2: String;
- begin
- max:=spin_max.Value;
- //------------SORTEIO1-------
- while res1<'1' do //REPETE O SORTEIO ATE QUE O NUMERO SEJA MAIOR QUE ZERO E VALIDO
- begin
- Randomize;
- res1:=FormatFloat('0', Random(max+1)); //GERA UM NUMERO ALEATORIO ENTRE 1 E O VALOR MAXIMO
- end;
- label_sort1.Caption:=res1; //DEFINE O PRIMEIRO GANHADOR
- //----SORTEIO2-------
- while res2<'1' do //REPETE O SORTEIO ATE QUE O NUMERO SEJA MAIOR QUE ZERO E VALIDO
- begin
- Randomize;
- repeat res2:=FormatFloat('0', Random(max+1)); //GERA UM NUMERO ALEATORIO ENTRE 1 E O VALOR MAXIMO
- until res2<>res1; //REPETE O SORTEIO SE O FOR O MESMO GANHADOR
- end;
- label_sort2.Caption:=res2; // DEFINE SEGUNDO GANHADOR
- end;
- procedure Tfrm_sorteador_tuneup.FormCreate(Sender: TObject);
- begin
- Randomize; // CONTROLE DO RANDOMSEED
- end;
- end.
- You can download full software and code at http://www.mediafire.com/?7oezhtu58g0ga - PASSWORD: tecdicas
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement