Dim former, latter, max As Integer Dim strr, maxstr As String Private Sub Form_Load() max = 0 Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, former, latter For i = former To latter strr = strr & Str(i) Next For i = 0 To 9 ori = Len(strr) strr = Replace(strr, i, "") If ori - Len(strr) > max Then max = ori - Len(strr): maxstr = i If Len(strr) = 0 Then Exit For Next Print #2, maxstr & " " & max Close #2 Close #1 End End Sub
Dim former, latter, max As Integer
回覆刪除Dim strr, maxstr As String
Private Sub Form_Load()
max = 0
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, former, latter
For i = former To latter
strr = strr & Str(i)
Next
For i = 0 To 9
ori = Len(strr)
strr = Replace(strr, i, "")
If ori - Len(strr) > max Then max = ori - Len(strr): maxstr = i
If Len(strr) = 0 Then Exit For
Next
Print #2, maxstr & " " & max
Close #2
Close #1
End
End Sub