排除重复
- Sub bbb()
- Dim arr, s$, s1$, n&, n1&, i&, d As Object
- Set d = CreateObject("scripting.dictionary")
- arr = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")
- n = InputBox("Please Input xxxxxx...")
- If Not IsNumeric(n) Then MsgBox "Error!": Exit Sub
- If n < 6 Or n > 18 Then MsgBox "Error!": Exit Sub
- Randomize (Now())
- Do
- s1 = arr(Int(Rnd() * 36))
- If Not d.exists(s1) Then
- d(s1) = ""
- s = s & s1
- n1 = n1 + 1
- End If
- Loop Until n1 = n
- [a1] = s
- End Sub
复制代码 |