用Rnd寫。
題目:
從某個數到某個數之間的(3的倍數)用隨機選取選出。
2006-07-10 06:03:07 · 1 個解答 · 發問者 咩 1 in 電腦與網際網路 ➔ 程式設計
'從a~bPrivate Sub Command1_Click() Dim a As Long, b As Long, n As Long Randomize Timer a = Int(Val(InputBox("請輸入起始值"))) b = Int(Val(InputBox("請輸入終值"))) If b < a Then n = a: a = b: b = n Do n = Int(Rnd * (b - a + 1) + a) Loop Until n Mod 3 = 0 Print nEnd Sub
2006-07-10 08:21:09 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋