Check if a number is Prime Number or not?

Posted by Rajesh_Kumar under VB.NET category on | Points: 40 | Views : 737
Dim num1,num2 As Integer
Dim is_prime_number As Boolean
num1 = txt_number.Text

is_prime_number = True

For num2 = 2 To (num1-1)
If num1 Mod num2 = 0 Then
is_prime_number = False
Exit For
End If
Next num2

If is_prime_number Then
MsgBox(num1 & " is a prime Number")
MsgBox(num1 & " is not a prime Number")
End If

Comments or Responses

Login to post response