怎样使以下随机函数不重复出现(VB)?

这是公司一个知识竞赛选题的ppt,想问一下,如何更改编程才能使题目不重复出现?请大神指教,谢谢!

第1个回答  2014-07-18
那预先把题号放在数组中,随机抽取一项后把该号从数组中去掉。
还是用集合较好,

声明区定义集合变量
dim cols as collection
先初始集合:
private sub initCols
set cols=new collection
dim i as integer
for i=1 to 55
cols.add i
next
end sub

产生题号:
dim index as integer
index=int(rnd*cols.Count+1) '这是产生一个随机索引
a=cols.item(index) '通过索引获取题号
cols.remove index '然后把该项去掉本回答被网友采纳
相似回答