Logo 
Search:

VB.Net Articles

Submit Article
Home » Articles » VB.Net » Utility CodeRSS Feeds

How to check the number is prime or not? Vb.Net code

Posted By: Ram Singh     Category: VB.Net     Views: 38909

How to check a number is prime or not. In Vb.net , it is very easy and simple code which can be use to check the number. for detail you can visit

this is a very simple code to check the number is prime or not 
Dim i, j As Integer
        Dim t As Boolean
        i = TextBox1.Text
        t = True
        For j = 2 To (i - 1)
            If i Mod j = 0 Then
                t = False
                Exit For
            End If
        Next j
        If t Then
            MsgBox(i & " is a prime Number")
        Else
            MsgBox(i & " is not a prime Number")
        End If
www.ram-a-singh.blogspot.com
  
Share: 


Didn't find what you were looking for? Find more on How to check the number is prime or not? Vb.Net code Or get search suggestion and latest updates.

Ram Singh
Ram Singh author of How to check the number is prime or not? Vb.Net code is from India. Ram Singh says

I am a freelance Vb.Net programmer from India and also do blogging which I have started last year

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Abiodun Olamilekan from Germany Comment on: Apr 23
hi,
please can you explain this code for me, because i dont understand how the variable "t" operates. i will b very happy if u can comment the code too.

Thanks.

View All Comments