取一个整数数组
我想要取一个整数数组,其中包含4-8个小于8的整数,并且不要重复的数字,我用以下函数不能避免重复数字的出现,请问有什么好办法能实现预想的要求。我用的是VB6.0
Private Function goodsNumber()
Dim goodsCount as Integer
Dim goods() as Integer
Randomize
goodsCount=Int(4*rnd())+3
Redim goods(goodsCount)
For i=0 To goodsCount
goods(i)=Int(8*Rnd())
Next
goodsNumber = goods
End Function