Private Sub Command1_Click()
Dim isPrime(100) As Boolean
Dim i As Integer, j As Integer
For i = 1 To 100
isPrime(i) = True
Next
For i = 2 To 100
If isPrime(i) = True Then
For j = 2 To 100
If i * j <= 100 Then
If isPrime(i * j) Then
isPrime(i * j) = False
End If
Else
Exit For
End If
Next
End If
Next
j = 0
Dim tmpstr As String
Open App.Path & "\1.txt" For Output As #1
For i = 2 To 100
If isPrime(i) Then
If j < 5 Then
tmpstr = tmpstr & Format(i, "00") & " "
j = j + 1
If j = 5 Then
Print #1, Trim(tmpstr)
tmpstr = ""
j = 0
End If
End If
End If
Next
Close #1
End Sub