我只发产生随机数的源码..至于怎么控制不会产生相同的字符串...就先不发..!
Dim cd As Collection
Dim Str() As Variant
Dim okStr(9999) As String
Dim rndInt1 As Integer
Dim rndInt2 As Integer
Dim rndInt3 As Integer
Dim rndInt4 As Integer
Dim rndInt5 As Integer
Dim rndInt6 As Integer
Dim rndInt7 As Integer
Dim rndInt8 As Integer
Dim rndInt9 As Integer
Dim rndInt10 As Integer
Dim rndInt11 As Integer
Dim rndInt12 As Integer
Dim rndInt13 As Integer
Dim rndInt14 As Integer
Dim rndInt15 As Integer
Dim rndInt16 As Integer
Private Sub Form_Load()
Randomize
Str = Array("q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", _
"z", "x", "c", "v", "b", "n", "m", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S", "D", _
"F", "G", "H", "J", "K", "L", "Z", "X", "C", "V", "B", "N", "M", "0", "1", "2", "3", _
"4", "5", "6", "7", "8", "9")
End Sub
Private Sub Command1_Click()
Randomize
Set cd = New Collection
For i = 0 To 9999
rndInt1 = Int(Rnd * 62)
rndInt2 = Int(Rnd * 62)
rndInt3 = Int(Rnd * 62)
rndInt4 = Int(Rnd * 62)
rndInt5 = Int(Rnd * 62)
rndInt6 = Int(Rnd * 62)
rndInt7 = Int(Rnd * 62)
rndInt8 = Int(Rnd * 62)
rndInt9 = Int(Rnd * 62)
rndInt10 = Int(Rnd * 62)
rndInt11 = Int(Rnd * 62)
rndInt12 = Int(Rnd * 62)
rndInt13 = Int(Rnd * 62)
rndInt14 = Int(Rnd * 62)
rndInt15 = Int(Rnd * 62)
rndInt16 = Int(Rnd * 62)
If i < 5000 Then
str1 = (Str(rndInt1)) & (Str(rndInt2)) & (Str(rndInt3)) & (Str(rndInt4)) _
& (Str(rndInt5)) & (Str(rndInt6)) & (Str(rndInt7)) & (Str(rndInt8)) _
& (Str(rndInt9)) & (Str(rndInt10)) & (Str(rndInt11)) & (Str(rndInt12)) _
& (Str(rndInt13)) & (Str(rndInt14)) & (Str(rndInt15)) & (Str(rndInt16)) _
& "#100"
cd.Add str1
ElseIf i >= 5000 And i <= 7999 Then
str1 = (Str(rndInt1)) & (Str(rndInt2)) & (Str(rndInt3)) & (Str(rndInt4)) _
& (Str(rndInt5)) & (Str(rndInt6)) & (Str(rndInt7)) & (Str(rndInt8)) _
& (Str(rndInt9)) & (Str(rndInt10)) & (Str(rndInt11)) & (Str(rndInt12)) _
& (Str(rndInt13)) & (Str(rndInt14)) & (Str(rndInt15)) & (Str(rndInt16)) _
& "#200"
cd.Add str1
Else
str1 = (Str(rndInt1)) & (Str(rndInt2)) & (Str(rndInt3)) & (Str(rndInt4)) _
& (Str(rndInt5)) & (Str(rndInt6)) & (Str(rndInt7)) & (Str(rndInt8)) _
& (Str(rndInt9)) & (Str(rndInt10)) & (Str(rndInt11)) & (Str(rndInt12)) _
& (Str(rndInt13)) & (Str(rndInt14)) & (Str(rndInt15)) & (Str(rndInt16)) _
& "#500"
cd.Add str1
End If
Randomize
For i = 1 To cd.Count
rndInt16 = Int(Rnd * cd.Count + 1)
gg = gg & cd.Item(rndInt16) & vbCrLf
cd.Remove (rndInt16)
Form1.Caption = cd.Count
Next
RichTextBox1.Text = gg
/images/2011/147787/2011051411021524.jpg" border="0" />