Displaying all prime numbers below 100 in VB 6.0
Private Sub DisplayPrimeNumbers()
Dim Num As Long
Dim NN As Long
Dim IsPrime As Boolean
For Num = 2 To 100
IsPrime = True
For NN = 2 To Int(Num / 2)
If Num Mod NN = 0 Then
IsPrime = False
Exit For
End If
Next
If IsPrime Then
MsgBox CStr(Num) + " is a prime number!"
End If
Next
End Sub
No comments:
Post a Comment