Mirror

How to randomly select records from a TTable (Views: 100)


Problem/Question/Abstract:

How to randomly select records from a TTable

Answer:

procedure TForm1.FormCreate(Sender: TObject);
begin
  randomize; {call only once}
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  table1.first;
  table1.MoveBy(Random(table1.recordcount));
end;

<< Back to main page