弄成函数
程序代码:
Clea
nMin1 = 31&&比例1的最小值范围
nMax1 = 80&&比例1的最大值范围
nMin2 = 81
nMax2 = 100
nMin3 = 0
nMax3 = 30
nRang1 = 20 &&比例1
nRang2 = 10 &&比例2
?x_RandRang(nRang1,nMin1,nMax1,nRang2,nMin2,nMax2,nMin3,nMax3)
Function x_RandRang(nRang1,nMin1,nMax1,nRang2,nMin2,nMax2,nMin3,nMax3)
nResult = 0
lcResult = ""
For i = 0 To 100
nRang = Int((100 - 0 + 1) * Rand( ) + 0)
Do Case
Case nRang <= nRang1
nResult = Int((nMax1 - nMin1 + 1) * Rand( ) + nMin1)
Case Between(nRang,nRang1 + 1 ,nRang1 + nRang2)
nResult = Int((nMax2 - nMin2 + 1) * Rand( ) + nMin2)
Otherwise
nResult = Int((nMax3 - nMin3 + 1) * Rand( ) + nMin3)
Endcase
lcResult = lcResult + Transform(nResult)+","
Endfor
Return lcResult
Endfunc