要求:
1、毫无规律可寻
2、从1-30 位长度用户定义
3、1-9 的数字构成 A-Z 字母
4、生成速度快,瞬间完成
5、不重复
望各位高手能告知实现方法,最好有算法的代码。
1、毫无规律可寻
2、从1-30 位长度用户定义
3、1-9 的数字构成 A-Z 字母
4、生成速度快,瞬间完成
5、不重复
望各位高手能告知实现方法,最好有算法的代码。
解决方案 »
- 以vbUnicode输出,光标不再定位了,为什么?
- 如何修改笔记本电脑网卡的物理
- 如何将图片转换成二进制,然后再将二进制转换成图片?
- 两天了,数据库可以查出来,vb就查不出来
- mscomm这个东东,到底要折磨偶多久,请大家帮帮忙了,谢谢!
- 急急急急急急急急急!vb中,如何实现access 数据库数据的导入导出,初学者请求源代码,谢谢
- about waitforsingleobject
- 我坚持VB的10大理由,和3大受益,大家还有补充的吗?
- 高分求教!关于远程访问Com组件的问题。
- 已知一个应用程序的路径和可执行文件名?如何判断其是否已经运行
- 有谁能讲讲关于vb+SQL Server的并发性问题
- 数据库连接怎么连接啊?
网上文章,参考一下:'============================='生成52个1到100的不重复随机数'=============================
Dim i, j As Long
Dim ran(1 To 52) As Long
Dim tNum As Long
Dim isExist As Boolean
RandomizeFor i = 1 To 52
isExist = False
tNum = Int(100 * Rnd + 1)
Debug.Print tNum
For j = 1 To i
If ran(j) = tNum Then
isExist = True
i = i - 1
Exit For
End If
Next
If isExist = False Then
ran(i) = tNum
End If
NextFor i = 1 To 52
msg = msg & ran(i) & Space(1)
Next
MsgBox msg
Dim str1 As String, str2 As String
Dim i As Integer, j As Integer, num As Long
Dim n As Integer, str_cnt As Long
Dim mei() As String
Dim isexist As Boolean
n = 30 '随机数的位数
num = 30 '要生成的随机数的个数
str2 = ""
str_cnt = 0
isexist = False
label1: str1 = ""
Randomize For j = 1 To n
i = Int(10 * Rnd)
str1 = str1 + Str(i)
Next j
If str_cnt = 0 Then
ReDim Preserve mei(str_cnt)
mei(str_cnt) = str1
str_cnt = str_cnt + 1
Else
For j = 0 To str_cnt - 1
If str1 = mei(j) Then
isexist = True
Exit For
End If
Next j
If isexist = False Then
ReDim Preserve mei(str_cnt)
mei(str_cnt) = str1
str_cnt = str_cnt + 1
End If
End If
If UBound(mei) + 1 = num Then
For j = 0 To str_cnt - 1
Debug.Print mei(j) + Chr(10) + Chr(13)
Next j
Else
GoTo label1
End If
End Sub