Private Sub Command1_Click() Dim c As String Dim i As Integer, j As Integer Dim a(9) As Integer Randomize For i = 1 To 7 j = Chr(Int(10 * Rnd) + 48) Do While a(j) <> 0 Or (i = 1 And j = 0) j = Chr(Int(10 * Rnd) + 48) Loop a(j) = 1 c = c & j Next i Print c End Sub
Dim c As String
Dim i As Integer, j As Integer
Dim a(9) As Integer
Randomize
For i = 1 To 7
j = Chr(Int(10 * Rnd) + 48)
Do While a(j) <> 0 Or (i = 1 And j = 0)
j = Chr(Int(10 * Rnd) + 48)
Loop
a(j) = 1
c = c & j
Next i
Print c
End Sub