Created
October 26, 2013 00:19
-
-
Save warham2012/7163809 to your computer and use it in GitHub Desktop.
Prime Number Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim numValue As Integer = 0 | |
Dim maxNumValue As Integer = 0 | |
Private Sub btnPrime_Click(sender As Object, e As EventArgs) Handles btnPrime.Click | |
lstPrimeNumbers.Items.Clear() | |
numValue += 1 | |
maxNumValue = txtMaxNumber.Text | |
For Me.numValue = 0 To maxNumValue | |
isNumberPrime() | |
Next | |
End Sub | |
Private Sub isNumberPrime() | |
Dim isPrime As Boolean = False | |
Dim a, c As Integer | |
a = numValue | |
c = 0 | |
For i = (a - 1) To 2 Step -1 | |
If a Mod i = 0 Then | |
c += 1 | |
End If | |
Next i | |
If c = 0 Then | |
isPrime = True | |
End If | |
If isPrime = True Then | |
lstPrimeNumbers.Items.Add(numValue) | |
End If | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment