7,759
社区成员
发帖
与我相关
我的任务
分享
Private Sub Command4_Click()
Debug.Print Int(20 * Rnd() + 1) 'Int((范围) * Rnd) + 基数 范围=上限-基数+1
End Sub
#include <windows.h>
#include <conio.h>
int i;
void main() {
cprintf("Please press space bar to generate random number between 0 and 9999 ...\r\n");
i=0;
while (1) {
if (_kbhit()) break;
Sleep(1);
i++;
if (i>=10000) i=0;
}
_getch();
cprintf("%d\r\n",i);
}
#include <windows.h>
#include <conio.h>
int i;
void main() {
cprintf("Please press space bar to generate random number between 0 and 9999 ...\r\n");
i=0;
while (1) {
if (_kbhit()) break;
Sleep(1);
i++;
if (i>=10000) i=0;
}
_getch();
cprintf("%d\r\n",i);
}
Private Sub Command1_Click()
Randomize
Text1.Text = Int(20 * Rnd) + 1
End Sub
用RND()最简单Private Sub Command1_Click()
Randomize
Text1.Text = Int(20 * Rnd) + 1
End Sub