VB随机抽取不重复数据如何实现? 用个数组每生成一个新数字的时候与前几个做比较如果重复的话返回重新生产如何用VB从几个文字中随机不重复抽取三个文字组成一个名字 Dim str As String,tmp As String,strx As StringDim n As Integer,i As IntegerRandomizestr=\"澳三地附近哦啊决定For i=0 To 2n=Int(Rnd()*Len(str))+1tmp=Mid(str,n,1)str=Replace(str,tmp,\"\")strx=strx&tmpNextMsgBox strxVB 点击命令按钮1,从1-10中随机抽取3个不重复的数,如何写代码 Private Sub Command1_Click()Dim a(2),i,jLabel1.Caption=\"For i=0 To 2Doa(i)=Int(Rnd*9)+1For j=0 To iIf i<;>;j And a(i)=a(j)Then Exit ForNextLoop Until j>;iLabel1.Caption=Label1.Caption&a(i)&IIf(i,;NextEnd Sub1楼 对的 只是两个地方 没注意 可能是太着急了用vb怎样生成10个不重复的(1到10)随机数? Private Sub Command1_Click()Dim a(9)As IntegerFor i=0 To 9way1:Randomizea(i)=Int(Rnd()*10)+1If i>;1 ThenFor p=0 To i-1If a(p)=a(i)Then‘与前面的对比,如果有重复,重新随机GoTo way1End IfNext pEnd IfPrint a(i)’打印Next iEnd Sub
随机阅读
- 横塘路在哪里 吴中区和安路在横塘怎么走
- 如何成为一名优秀的银行客户经理? 协助银行客户经理尽调
- 儿童适合跳拉丁舞吗? 宫廷舞蹈症我没有我儿子会有吗
- 简述建筑物防雷装置的组成及作用原理。 防雷保护装置主要的手段
- 传送带与水平面的夹脚
- 溧水中山水苑在哪里 南京周边有哪些适合短途旅行的地方?
- 费舍尔0.4超时 德里克·费舍尔0.4秒绝杀。。。
- 水佐岗在哪里 家住南京巿鼓楼区水佐岗,想乘坐机场大巴到禄口机场在哪里坐最近
- 谢里夫访香港三天 2017 年 Q1 阿里财报表现超越腾讯,AT 谁会成为未来最大的赢家?
- 鑫晖达机械在哪 天津市鑫辉机械有限公司怎么样?
- 有什么KTV里适合唱的,逼格比较高的歌曲? 此处行人须止步打一成语
- 剑三 蹑云重制版2018 百度安全验证
- 怀孕前男人吃什么最好的 孕前男人吃什么好?
- 有没有一款好的补水霜?贝瑞滋多效补水精华霜怎么样? 贝瑞滋产品怎么样
- 氨糖软骨素?到底有用吗? 永信表行 jf 爱彼
- 兰蔻水份缘舒缓凝霜和舒缓日霜 想入手兰蔻水份缘系列,夏天用不知道选择乳液还是日霜,而且舒缓凝霜是什么时候用的?和日霜有什么区别?
- 汉寿县毛家滩集镇 汉寿县乡镇合并毛家滩是怎么合并的
- amd锐龙现在还有小毛病吗?据说软件支持不太好,迷之卡顿,实际使用到底如何? 飞跃死城2购物中心
- 如今的娱乐圈中有哪些明星是汉中的明星? 那些明星是陕西汉中人
- 巴西国有银行 问一个关于巴西