- 1、本文档共14页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
vb生成不重复的随机数(VB generates random numbers that are not repeated)
vb生成不重复的随机数(VB generates random numbers that are not repeated)
VB generates random numbers that are not repeated
My suggestion is: the first step, first make a deposit on the array, the number 35 (which may not be continuous, can also be a string of names, what); the second step, generates a random number between 1-35 and output; the third step: the first element of the array and the number of pay in the fourth step, the output from the array; the 2-35 between second randomly selected number; fifth step, the second unit second random number and the array this call number; the sixth step, a random sample of third output..... Repeat to draw a random number between the 35-35 numbers, then direct the last one.
The program is as follows (VB6):
On the default form in the project, draw a Command1, paste program:
Option explicit
Private vArray (1, to, 35) as currency defines the number of arrays
Private, sub, command1_click ()
Test
End Sub
Private, sub, InitArray ()
Dim I as long
Assign an array
For i=1 to 35
Varray (I) =i
Next I
End Sub
Private, sub, Test ()
Dim iStart as long
Dim iPos as long
Dim vTemp as currency
Dim sReturn as string
InitArray
Randomize timer sets random factors so that the random number of programs they run every time is different
IStart=1
Do
IPos=int (rnd* (UBound (vArray), -iStart+1)) +iStart produces an integer between iStart and 35 (35 taken from vArrays superscript)
SReturn=sReturn vArray (iPos) vbcrlf output
Unit content
VTemp=vArray (iStart)
VArray (iStart) =vArray (iPos)
VArray (iPos) =vTemp
IStart=iStart+1 next time it is randomly generated, one less is generated
If iStart=ubound (vArray) then
The last one, the direct output
SReturn=sReturn vArray (UBound (vArray))
Exit Do
End if
If iStart7 then exit do if you need to generate several numbers, change 7 to several, greater than the number of array elements, and the number of elements that will output the speed (this example is 35)
Loop
Msgbox sReturnmsgbox output results
End Sub
============
您可能关注的文档
- oracle 锁机制42(Oracle锁机制42).doc
- ofdm基本原理及应用(Fundamentals and applications of OFDM).doc
- oracle_11gr2_11 事务transaction - 四大特性(原子性,一致性,隔离性,永久性)和相应的例子来演示(oracle _ 11gr2 _ 11 事务transaction - 四大特性 (原子性, 一致性, 隔离性, 和相应的例子来演示 永久性)).doc
- oracle中如何删除重复数据(How to delete duplicate data in Oracle).doc
- oracle删除重复记录(Oracle deletes duplicate records).doc
- oracle事务(oracle事务).doc
- oracle去重复数据(Oracle to repeat data).doc
- oracle学习目标(oracle学习目标).doc
- oracle sql loader 的使用方法(Oracle SQL Loader的使用方法).doc
- oracle常用语法(Oracle common syntax).doc
- 2024年领导在破解基层整治管理“小马拉大车”突出问题重点任务推进会上的发言稿3篇【供参考选用】.docx
- 在2024年破解基层整治管理“小马拉大车”突出问题推进会发言稿2篇文.docx
- 在2024年全面破解基层整治管理小马拉大车突出问题重点任务推进会上的发言稿2篇文.docx
- 2篇:某领导干部在2024年破解基层整治管理“小马拉大车”突出问题重点任务推进会上发言稿.docx
- 三篇在2024年破解基层整治管理“小马拉大车”突出问题重点任务推进会上的发言稿.docx
- 在2024年破解基层整治管理“小马拉大车”突出问题重点任务推进会上发言稿2篇稿【供参考】.docx
- 2024年党员领导在破解基层整治管理“小马拉大车”突出问题重点任务推进会上发言稿(2篇文).docx
- 机械设计制造及其自动化滚齿机传动轴的力学分析.doc
- 机制论文热处理工艺对镍磷合金镀层硬度的影响.doc
- 机械设计制造及其自动化论文基于PLC的电阻炉控制.doc
文档评论(0)