欢迎光临 石陆软件屋  首页 原创软件   VB文挡  VB资源   乱舞人生  资源   Tags  给我留言 
用户登陆
用户:
密码:
 

站点日历
73 2024 - 5 48
   1234
567891011
12131415161718
19202122232425
262728293031


站点统计

最新日志
任务拦高度 屏蔽文本框点右键时的弹出菜单
晴天 随机字母的函数   [ 日期:2006-10-21 ]
该过程由作者原创,就是速率可能不是很高
我考虑用个辅助过程,加快其速度
程序代码:[ 复制代码 ] 
Function RandABC(N As Long, Optional Model As Long = 1) As String
''N是你想要得到字符串的长度
''Model是你想得到大写还是小写字母,1--混合大小写,2--大写,3--小写"
Dim StrDiaoyong As String
Const StrHunhe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
Const StrDaxie = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Const StrXiaoxie = "abcdefghijklmnopqrstuvwxyz"
Select Case Model
Case 1
StrDiaoyong = StrHunhe
Case 2
StrDiaoyong = StrDaxie
Case 3
StrDiaoyong = StrXiaoxie
End Select
If N <= 20000 Then
For i = 1 To N
Randomize
RandABC = RandABC & Mid(StrDiaoyong, Int(Rnd * (Len(StrDiaoyong) - 1 + 1) + 1), "1")
Next i
Else
MsgBox "N值太大了,计算机缓冲不过来"
End If
End Function





以下来自iceboy的

程序代码:[ 复制代码 ] 
Public Function RandomStr(ByVal Length As Long) As String
    Const RandomChar As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    Dim RandomBytes() As Byte, RandomCharCount As Long, Result() As Byte, i As Long, p As Long
    If Length <> 0 Then
        Randomize
        RandomBytes = RandomChar
        RandomCharCount = UBound(RandomBytes) \ 2 + 1
        ReDim Result(Length * 2 - 1)
        For i = 0 To Length - 1
            p = Int(Rnd() * RandomCharCount)
            Result(i * 2) = RandomBytes(p * 2)
            Result(i * 2 + 1) = RandomBytes(p * 2 + 1)
        Next
        RandomStr = Result
    End If
End Function



相关链接:vb | 随机字母 | 函数 | 过程

[阅读字体大小: ]
[本日志由 admin 于 2013-11-01 10:46 PM 编辑]
引用通告地址 (0):
复制引用地址http://www.cnng.net/blog/trackback.asp?tbID=23
复制引用地址http://www.cnng.net/blog/trackback.asp?tbID=23&CP=GBK
暂时没有评论
发表评论 - 不要忘了输入验证码哦!
作者: 用户名:  密码:   注册? 验证码: 
评论:

禁止表情
禁止UBB
禁止图片
识别链接
识别关键字
表  情