顯示在 ListBox 中
Private Sub Command1_Click()
Dim i, j, k As Integer
Dim a As String
Dim b As Boolean
k = 0
For i = 2 To 100
b = False
For j = 2 To i - 1
If i Mod j = 0 Then
b = True
Exit For
End If
Next j
If Not b Then
k = k + 1
s = s & Str(i)
If k = 6 Then
List1.AddItem s
s = ""
Next i
If s <> "" Then List1.AddItem s
End Sub
顯示在 ListBox 中
Private Sub Command1_Click()
Dim i, j, k As Integer
Dim a As String
Dim b As Boolean
k = 0
For i = 2 To 100
b = False
For j = 2 To i - 1
If i Mod j = 0 Then
b = True
Exit For
End If
Next j
If Not b Then
k = k + 1
s = s & Str(i)
If k = 6 Then
List1.AddItem s
s = ""
k = 0
End If
End If
Next i
If s <> "" Then List1.AddItem s
End Sub