Gerar Numeros Aleatorias

Delphi

13/11/2003

Como faco uma rotina(tipo function) que retornara um valor aleatorio??

exemplo:

label1.caption:= funcRandom(5);

5 foi o valor enviado....

O retorno pode ser string ou integer, mas o valor retornado deve ser um destes: -5 , -4 , -3 , -2 , -1 , 0 , 1 , 2 , 3 , 4 , 5

Obrigado deste ja


Andcarpi

Andcarpi

Curtidas 0

Respostas

Ivonei

Ivonei

13/11/2003

Veja se é isto:

Label1.Caption:= IntToStr(RandomRange(-5, 5));


Coloque Math na seção uses. :wink:

Fui.


GOSTEI 0
Andcarpi

Andcarpi

13/11/2003

Valeu cara, Funcionou [b:4e9d253c3e]certinho!!!![/b:4e9d253c3e]


GOSTEI 0
Rômulo Barros

Rômulo Barros

13/11/2003

randomize ; numale := randomrange(1,100);


GOSTEI 0
POSTAR