VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   375
      Left            =   3000
      TabIndex        =   0
      Top             =   2760
      Width           =   1095
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Click()
 Dim s(1 To 15) As String * 1, c As String * 1
 s(1) = Chr(Int(Rnd * 26 + 65))
 n = 2
 For n = 2 To 15
re:    c = Chr(Int(Rnd * 26 + 65))
       For j = 1 To n - 1
       ' 找到有重复字母，重新产生
         If s(j) = c Then GoTo re
       Next j
      s(n) = c
 Next n
 For i = 1 To 15
   Print s(i);
 Next i
End Sub

Private Sub Form_Click()
 Dim s(1 To 15) As String * 1, c As String * 1, Found As Boolean
 s(1) = Chr(Int(Rnd * 26 + 65))
 n = 2
 Do While n <= 15
    c = Chr(Int(Rnd * 26 + 65))
    Found = False
    For j = 1 To n - 1
        If s(j) = c Then Found = True
    Next j
    If Not Found Then                      ' 没有找到，产生的字母非重复，存放到数组中
      s(n) = c
      n = n + 1
    End If
 Loop
 For i = 1 To 15
   Print s(i);
 Next i
End Sub
 

 
 
 

