by Douglas Nelson (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 27th March 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Detecting Prime Numbers.
API Declarations
Put a Command Button called command1 on the form and a text box called text1
Put the amount of numbers you want it to count up to in text1. Click on command1 and the program will calculate all the prime numbers up to that number. It will output in a file called primenumbers.txt in the same directory as the program is
b = ""
For i = 1 To Text1.Text
n = 1
For m = 2 To i
If m = i Then
If n = 1 Then
b = b & i & ", "
GoTo restart1
End If
End If
If i / m = Round(i / m, 0) Then
n = 0
End If
restart1:
Next
Next
Open App.Path & "\primenumbers.txt" For Output As #1
Print #1, b
Close #1
End Sub