So I'm taking this introductory class on Visual Studio 2008 and I've been pretty lost since it started. Our current project is to write a code that will allow you to type in a starting and ending point then click the calculate button to calculate the factors of each number in the current range and display that in listbox1 then lablel1 needs to have a count of all the prime numbers that exist in that range and listbox 2 needs to show a list of all those prime numbers. My code currently calculates all of the factors in the range but I need help calculating the prime numbers and showing the count in label1 and the actual numbers in listbox2. If anyone has any suggestions they would be greatly appreciated. Here is my current code, i know its sloppy so if you have any suggestions to clean it up they would be appreciated as well.

Private Sub CalculateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateToolStripMenuItem.Click

Dim beginInteger, endInteger As Integer

Dim primeInteger, prime1Integer, displayInteger As Integer

Dim remainderInteger, primeNumberInteger As Integer

Dim outputString As String

beginInteger = CInt(fromTextBox.Text)

endInteger = CInt(toTextBox.Text)

ListBox1.Items.Add(" N Factors")

primeInteger = 0

For primeInteger = beginInteger To endInteger

displayInteger = primeInteger.ToString("D4")

outputString = Format(prime1Integer, "0000") & " "

For prime1Integer = 1 To primeInteger

remainderInteger = primeInteger Mod prime1Integer

If remainderInteger = 0 Then

'primeNumberInteger += 1

outputString &= " " & prime1Integer

End If

Next

ListBox1.Items.Add(outputString)

Next

End Sub