...存放于数组prime中。并将所找到的数,按每行10个的形式显示在窗体上...
发布网友
发布时间:2024-10-24 13:32
我来回答
共1个回答
热心网友
时间:2天前
Option Explicit
Private Sub Form_Click()
Dim i As Long, j As Long, n As Integer, prime() As Integer
For i = 1 To 100
If fc(i) Then
n = n + 1
ReDim Preserve prime(1 To n)
prime(n) = i
End If
Next
For i = 1 To n
Print prime(i);
If i Mod 10 = 0 Then Print
Next
Print: Print "共有:" & n
End Sub
Function fc(a) As Boolean
Dim i As Long
For i = 2 To Int(a / 2)
If a Mod i = 0 Then Exit For
Next
If i = Int(a / 2) + 1 Then fc = True
End Function