Private Sub Command1_Click()
Dim s As Integer
Dim s1 As String
Dim a(0 To 9) As Boolean
For i = 0 To 9
a(i) = True
Next
Randomize
Do
s = Int(10 * Rnd)
If a(s) = True Then
s1 = s1 & Trim(Str(s))
If Mid(s1, 1, 1) = 0 Then
s1 = ""
End If
a(s) = False
i = Val(Len(Trim(s1)))
End If
Loop While i < 8
Text1.Text = s1
End Sub