Delphi高手help我!!~~

2006-12-13 4:07 am
我想做一個程式.....
要用memo同一個按鈕!
按鈕一按下去就係memo產生隨機數(1~10)!!
直至連續兩個相同數字就停下來!~~~!!
就係咁!!
將程式碼由頭到尾貼上來!!!
thx!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

回答 (2)

2006-12-17 6:08 pm
✔ 最佳答案

圖片參考:http://hk.yimg.com/i/icon/16/1.gif
用Delphi 的 Random function ,見如下:

Declaration:
function Random[(MaxValue: Integer)];

Description
Returns a randomly generated number within a specified range.
If MaxValue is not specified Random returns a real number X where 0 <= x <1. If MaxValue is specified the X than falls between 0 and MaxValue. To initialize the random number generator, call (once) the Randomize procedure.

Example:




Randomize;

Random; // results in a random number 0 <= x <1
Random(50); // results in a random number 0 <= x <50

Randomize, RandomRange, RandomFrom,
2006-12-17 6:09 pm
You can use the Random(10) to achieve your goal.
Please do the remaining by yourself.


收錄日期: 2021-04-23 16:26:42
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20061212000051KK03755

檢視 Wayback Machine 備份