VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Checking whether a number is a prime number

by Abdul Jalil (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 5th June 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Checking whether a number is a prime number

Rate Checking whether a number is a prime number



Dim primNum As Integer
Dim i As Integer
Dim isPrime As Boolean
isPrime = True

primNum = Val(Text1.Text)
For i = 2 To (primNum - 1)
    If primNum Mod i = 0 Then
        isPrime = False
    End If
Next

If isPrime = False Then
    Picture1.Print Str(primNum) + " Not a prime number"
Else
    Picture1.Print Str(primNum) + " Is a prime number"
End If
End Sub


Download this snippet    Add to My Saved Code

Checking whether a number is a prime number Comments

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

Post your comment

Subject:
Message:
0/1000 characters