var Form1: TForm1; ButtonArray : array [0..10] of TButton; implementation {$R *.dfm} Procedure Reordenar(); var i, j, doing: Integer; exists: boolean; begin doing:=0; repeat exists:=false; i:=random(9)+1; for j:=0 to doing do if ButtonArray[j].caption=IntToStr(i) then begin exists:=true; break; end; if exists=false then begin ButtonArray[doing].Caption:=IntToStr(i); inc(doing); end; until (doing=9) and (exists=true) end; procedure TForm1.FormCreate(Sender: TObject); var i, j: Integer; begin randomize; i:=0; for j := 0 to ComponentCount-1 do if (components[j].classtype = TButton) then begin ButtonArray[i] := TButton(Components[j]); inc(i); end; Reordenar(); end; procedure TForm1.Button10Click(Sender: TObject); begin reordenar(); end;