VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Determine if a number is a prime number

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

Rate Determine if a number is a prime number



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

Download this snippet    Add to My Saved Code

Determine if a number is a prime number Comments

No comments have been posted about Determine if a number is a prime number. Why not be the first to post a comment about Determine if a number is a prime number.

Post your comment

Subject:
Message:
0/1000 characters