求编写一个简单的VB程序
来源:百度知道 编辑:UC知道 时间:2024/05/30 08:10:58
Function isprime(Num As Long) As Boolean
If Num < 2 Then isprime = False: Exit Function
Dim i As Long
For i = 2 To Sqr(Num)
If (Num Mod i) = 0 Then
isprime = False
Exit Function
End If
Next i
isprime = True
End Function
Private Sub Command1_Click()
Dim i As Long
Dim n As Long
For i = 1 To 100
If isprime(i) Then n = n + 1
Next i
Print "1到100之间素数的个数:"; n
End Sub
这个要找专业人士才能解决了!
Option Explicit
Function IsSS(ByVal iNumber As Integer) As Boolean
IsSS = True
Dim i As Integer
For i = 2 To iNumber - 1
If (iNumber Mod i = 0) Then
IsSS = False
Exit Function
End If
Next i
End Function
Sub FindSS(ByVal iFrom As Integer, ByVal iTo As Integer)
Dim i As Integer
For i = iFrom To iTo