Private Sub Command1_Click() Dim a(9) As Integer Dim b(9) As Integer Dim seq() As Integer ct = 0: Open "c:\tsf_output.txt" For Output As #1 For s = 0 To 200000 t = Trim(Str(s)) For i = 1 To Len(t) c = Int(Mid(t, i, 1)) b(c) = b(c) + 1 Next i t1 = s Mod 10 t2 = (s - t1) / 10 If b(t1) = t2 Then For i = 0 To 9 a(i) = b(i) Next i ct = ct + 1: ReDim Preserve seq(ct) As Integer: seq(ct) = s tb = t1 * 8 If (tb < ltb) Or (lt2 <> t2) Then Print #1, "" Print #1, Tab(tb); s; " "; ltb = tb lt2 = t2 Else For i = 0 To 9 b(i) = a(i) Next i End If Next s Print #1, "" Print #1, "" Print #1, ct; " terms" Print #1, "" Print #1, "["; For i = 1 To ct Print #1, Trim(Str(seq(i))); If (i <> ct) Then Print #1, ", "; If (i Mod 16) = 0 Then Print #1, "" Next i Print #1, "]" Print #1, "" Print #1, "Final values for each digit:" Print #1, "" For i = 0 To 9 Print #1, Trim(Str(i)); ":"; a(i) Next i Close #1 End Sub