1个回答
2013-11-28
展开全部
VB中的连字符是:& 符号给你全部代码,完全按照你的要求做到。Function MakeStr(nLength As Integer) As String
'随机生成指定长度的字符串,包括英文字母(不区分大小写)和数字
Randomize
For i = 1 To 20
r = Int(Rnd * 3)
Select Case r
Case 0 '数字
MakeStr = MakeStr & Int(Rnd * 10)
Case 1 '小写字母
MakeStr = MakeStr & Chr(Int(Rnd * 26) + 97)
Case 2 '大写字母
MakeStr = MakeStr & Chr(Int(Rnd * 26) + 65)
End Select
Next
End FunctionPrivate Sub Command1_Click()
m = MakeStr(5)
s1 = Left(m, 5)
s2 = Left(m, 10)
s3 = Left(m, 15)
s4 = s1 & "&" & s2 & "&" & s3 & "&" & s4
Print s4
End Sub
'随机生成指定长度的字符串,包括英文字母(不区分大小写)和数字
Randomize
For i = 1 To 20
r = Int(Rnd * 3)
Select Case r
Case 0 '数字
MakeStr = MakeStr & Int(Rnd * 10)
Case 1 '小写字母
MakeStr = MakeStr & Chr(Int(Rnd * 26) + 97)
Case 2 '大写字母
MakeStr = MakeStr & Chr(Int(Rnd * 26) + 65)
End Select
Next
End FunctionPrivate Sub Command1_Click()
m = MakeStr(5)
s1 = Left(m, 5)
s2 = Left(m, 10)
s3 = Left(m, 15)
s4 = s1 & "&" & s2 & "&" & s3 & "&" & s4
Print s4
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询