在下面这个判断素数的程序中首行Private Sub Form_Click() 是什么?为何会出现?

2024-12-21 15:04:15
推荐回答(1个)
回答1:

Private Sub Form_Click()
Dim n As Integer, i As Integer
n = InputBox("请输入要判断的数")
Call zh(n, i)
End Sub
Private Sub zh(n, i As Integer) ← 这里是sub
If n = 2 Or n = 3 Then
Print n & "是素数"
Else
For i = 2 To Sqr(n)
If n Mod i = 0 Then Exit For
Next i
If i > Sqr(n) Then
Print n & "是素数"
Else
Print n & "不是素数"
End If
End If
End Sub

希望能帮助你 感谢采纳