title: Checklistbox Multiple Selection
body: <p>I have been working on a application that uses a Checkedlistbox so I can allow the user to select multiple boxes. </p>
  
  <pre><code>    Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
      For Each item As Object In Me.CheckedListBox1.CheckedItems
          Dim text As String = Me.CheckedListBox1.GetItemText(item)
      Next
  
      If text = "Line 1" Then
          CreateLine1()
      End If
  
      If text = "Line 2" Then
          CreateLine2()
      End If
  
      If text = "Line 3" Then
          CreateLine3()
      End If
  
      If Text = "Line 4" Then
          CreateLine4()
      End If
  
      If Text = "Line 5" Then
          CreateLine5()
      End If
  </code></pre>
  
  <p>It goes all the way to "Line 10". When the app runs it use cmd.exe to connect to telnet and send commands. If I have Line 1 and Line 2 selected Line 1 has no problems, but when Line 2 run it opens a cmd does, nothing for a few seconds, open another cmd, and run just the commands while not connected to the telnet. Several more widows open afterwords and the four or fifth window connected to telnet.</p>
  
  <p>How can I make it so if one line if selected after it has run telnet it separates out that line as "Has been ran" before going to the next line to avoid my problem.</p>
  
  <p><strong><em>Addition info:</em></strong>
  This app has a select-all and deselect-all buttons so I can not have anything that will interfere with them.</p>
  
  <p>I have try using socket to replace cmd.exe.....it did not go so well and I will pass on it. </p>
  
  <p>Each sub the lines go to it basically the same except to the IP address and a few commands.</p>