Function Isprime(n%) As Boolean
Dim i%
Isprime = True
For i = 2 To n - 1
If n Mod i = 0 Then
Isprime = False
Exit Function
End If
Next i
End Function
Private Sub Command1_Click()
Dim a%, b%, i%
a = Val(Text1.Text)
b = Val(Text2.Text)
Text4.Text = ""
For i = a To b
If Isprime(i) Then Text4.Text = Text4.Text & i & " "
Next i
End Sub
Text4.Text = Text4.Text & i & " "中的i为什么不是str(i)
四季花海
相关分类