by Randy Houck (6 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 25th October 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Determine if a number is a prime number
API Declarations
'make a textbox
'make 2 command buttons
End
End Sub
Private Sub Command2_Click()
Dim testnum As Integer
Dim divisor As Integer
testnum = Text1.Text
divisor = 1
If testnum > 1 Then
Do
divisor = divisor + 1 'increment divisor
Loop While testnum Mod divisor <> 0
End If
If divisor = testnum Then
Label1.Caption = "Prime Number"
Else
Label1.Caption = "Not a Prime Number"
End If
End Sub
Private Sub text1_change()
Label1.Caption = ""
End Sub