没事就折腾一下,各位大大有没有写过一定范围内按比例出随机数?
如:随机0~100的整数,0~30占70%,31~80占10%,81~100占20%这样?
clea nMin1 = 31 nMax1 = 80 nMin2 = 81 nMax2 = 100 nMin3 = 0 nMax3 = 30 nResult = 0 lcResult = "" For i = 0 To 100 nRang = Int((100 - 0 + 1) * Rand( ) + 0) Do Case Case nRang <=10 nResult = Int((nMax1 - nMin1 + 1) * Rand( ) + nMin1) Case Between(nRang,11,30) nResult = Int((nMax2 - nMin2 + 1) * Rand( ) + nMin2) Otherwise nResult = Int((nMax3 - nMin3 + 1) * Rand( ) + nMin3) Endcase lcResult = lcResult + Transform(nResult)+"," Endfor ?lcResult