Hey guys, I needed to make a program for finding prime numbers. The logic is that you have to put limits n & m and then LOOP and odd-integer P between n & m inclusive. I have a button to click on my form that displays 2 message boxes, one saying " enter upper limit" and the other say "enter lower limit". I need now to get the results of the odd prime numbers between the limits into a list box! How do I do that? Am I doing something wrong? I am new at the visual basic... I would appreciate your help. Thanks, S

Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
        Dim Isprime As Integer
        Dim str As String
        Dim n As Integer
        Dim TestLimit As String
        Dim TestPrime As String
        Dim TestNum As String


        str = ""
        n = InputBox("Enter Upper limit")
        n = InputBox("Enter lower limit")
        If (n > 50) Then
            MsgBox("outside range")
            Exit Sub

        End If

        '   
        ' 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