title: Visual Basic: How can i display the prime numbers between 1 and the inputted number
body: <p>Hello everyone so i'm trying to find the prime numbers of any input. I want them to be in a listbox and the input in a text box. I would like to use two arguments but i don't know how to. this is the code i have i need dire help. I am not the best at visual basic i just need some guidance. My code isn't working but display a drop down box when i press display. </p>
  
  <pre><code>Public Class Form1
      Private Sub Button3_Click_1(sender As Object, e As EventArgs) Handles Button3.Click
  
          Dim prim As Integer
          Dim test As Integer
          Dim imPrime As Boolean = False
          prim = CInt(txtNum.Text)
          test = prim
  
          If prim = 1 Then
              imPrime = False
              MessageBox.Show("Enter a number greater than one please")
          Else
              Do While prim &gt;= 2
                  For i As Integer = 2 To prim
                      If prim Mod i = 0 Then
                          imPrime = False
                          Exit For
                      Else
                          imPrime = True
                          lstPrime.Items.Add(prim)
                      End If
                  Next
              Loop
          End If
          If imPrime = True Then
              lstPrime.Items.Add(prim)
          End If
  
      End Sub
  End Class
  </code></pre>