I had to create a program that calculated prime numbers. The logic is that you have to imput limits n & m and then LOOP and ODD integer P between n & m inclusive. I think I have the code write for calculating the primes, but I just don't know how to display the prime numbers in a list box? I need to know if this code is right first. Help would be highly appreciated! ( I am new at this, ive tried everything to make this work)

Thanks,

S

Dim Isprime As Integer Dim TestLimit As Long Dim TestPrime As Long Dim TestNum As Long ' ' Eliminate even numbers If TestPrime Mod 2 = 0 Then Exit Sub ' Loop through ODD numbers starting with 3 TestNum = 3 TestLimit = TestPrime Do While TestLimit > TestNum If TestPrime Mod TestNum = 0 Then ' Uncomment this if you really want to know ' MsgBox "Divisible by " & TestNum Exit Sub End If ' There's logic to this. Think about it. TestLimit = TestPrime \ TestNum ' Remember, we only bother to check odd numbers TestNum = TestNum + 2 Loop ' If we made it through the loop, the number is a prime. Isprime = True End Sub End Class