user2150717
user2150717

Reputation:

Random numbers with one answer

I have this code

label1.Caption:= 'Number is:' + inttostr(random(2) + 1);

but in result I have "1" every time. Can you explain what I did wrong?

Upvotes: 0

Views: 122

Answers (1)

RRUZ
RRUZ

Reputation: 136391

To initialize the random number generator you must call Randomize method before to use the random function.

Upvotes: 6

Related Questions