Sample code for 30+ languages & platforms
Delphi ActiveX

Generating Random Integer in Range

See more PRNG Examples

Demonstrates how to generate random integers in a specified range.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
fortuna: TChilkatPrng;
i: Integer;

begin
success := 0;

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

success := 0;

fortuna := TChilkatPrng.Create(Self);

// Generate random integers between 12 and 24 inclusive

for i := 0 to 100 do
  begin
    Memo1.Lines.Add(IntToStr(fortuna.RandomInt(12,24)));
  end;
end;