函数:
Function Generate()
Dim s As Integer
Dim rndNo As Integer
Dim strResult As String
s = 0
Randomize
Do Until s = 5
rndNo = Int(Rnd(1) * 34) + 1
If Not Nz(strResult, 0) Like "*" & rndNo & "*" Then
strResult = strResult & "-" & rndNo
s = s + 1
End If
Loop
Dim lNo As Integer
s = 0
lNo = 0
Do Until s = 2
rndNo = Int(Rnd(1) * 11) + 1
If rndNo <> lNo Then
strResult = strResult & "-" & rndNo
lNo = rndNo
s = s + 1
End If
Loop
Generate = Mid(strResult, 2)
End Function
调用:
Generate()
结果: