Private Function prime(s As Integer) As Boolean
Dim a As Integer
Dim yes As Boolean
yes = True
For a = 2 To s \ 2
If s Mod a = 0 Then
yes = False
Exit For
End If
Next a
End Function
Private Sub command1_click()
Dim s%, s1%, s2%
s = Val(InputBox("輸入大於六的正整數"))
If prime(s) Then
Print s; "是素數"
Else
Print s; "不是素數"
End If
End Sub
前面是看懂了,但是這塊不明白
麻煩講解下怎麼可以直接 用If語句加函數 來調用函數
本人是菜鳥,麻煩講解細緻點