Prime Number Checker

Talk about your favorite PC games, Steam and building awesome custom rigs!

Moderator: Moderators

Locked
ghosstt
Senior Member
Posts: 1551
Joined: Mon Feb 26, 2007 4:14 pm

Prime Number Checker

Post by ghosstt »

vb.net here is my code.. trying to check if a number is a prime number or not..

Code: Select all

Dim intNumber As Integer
        Dim intCouting As Integer
        Dim bool As Boolean
        Dim strings As String



        intNumber = Val(TextBox1.Text)

        If intNumber < 0 Then
            MessageBox.Show("Please Insert A Positive Integer")
            TextBox1.Text = Nothing
            bool = False
        End If

        For intcounting = 2 To intNumber Step 1
            If intNumber Mod intcounting <> 0 Then
                bool = False
            Else
                bool = True
            End If

        Next intcounting

        If bool = True Then
            RichTextBox1.Text = Nothing
            RichTextBox1.Text = "prime"
        ElseIf bool = False Then
            RichTextBox1.Text = Nothing
            RichTextBox1.Text = "notprime"
        End If
Skyone
Moderator
Posts: 6390
Joined: Tue Nov 29, 2005 8:35 pm
Location: it is a mystery
Contact:

Post by Skyone »

Why do you have two topics of the same purpose?
Locked