2011-12-11 35 views
2

我想在Delphi XE2中使用隨機範圍函數,但由於某些原因,它在嘗試運行時會一直給我一個未聲明的標識符錯誤,這裏是我的代碼。RandomRange函數'Undeclared Identifier'錯誤?

var 
    Form3: TForm3; 
    number_of_digits, values, single, doubledig, triple, four, I : nativeint; 

implementation 

{$R *.dfm} 

procedure TForm3.Button1Click(Sender: TObject); 

begin 
    Randomize; 
    number_of_digits := radiogroup1.ItemIndex; 
    single := RandomRange(0, 9); 
    doubledig := RandomRange(10,99); 
    triple := RandomRange(100,999); 
    four := RandomRange(1000,9999); 
    case number_of_digits of 
    0 : values := single; 
    1 : values := doubledig; 
    2 : values := triple; 
    3 : values := four; 
    end; 

我得到的錯誤是

E2003未說明的標識符RandomRange'

任何幫助,將不勝感激..謝謝。

回答

5

RandomRange功能在Math單位。將該單元添加到您的uses子句中。

uses 
    System.Math;