Public Class frmControlTest
  Inherits System.Windows.Forms.Form

  ' Kod generowany przez Windows Form Designer 


  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
                System.EventArgs) Handles MyBase.Load

    cmbSandwich.Items.Add("Hamburger")       ' Typ kanapki 
    cmbSandwich.Items.Add("Breaded Tenderloin")
    cmbSandwich.Items.Add("Sub")
    cmbSandwich.Items.Add("Liverwurst")
    cmbSandwich.Items.Add("Ham")
    cmbSandwich.Items.Add("Turkey")
    cmbSandwich.Items.Add("Chicken")
    cmbSandwich.Items.Add("Aunt Nancy’s Special")
    cmbSandwich.Items.Add("Joyce’s Jumbo Special")
    cmbSandwich.SelectedIndex = 0
    lsbCondiments.Items.Add("Yellow Mustard")    ' Dodatki
    lsbCondiments.Items.Add("Honey Mustard")
    lsbCondiments.Items.Add("Grey Poupon")
    lsbCondiments.Items.Add("Onion")
    lsbCondiments.Items.Add("Relish")
    lsbCondiments.Items.Add("Peppers")
    lsbCondiments.Items.Add("Lettuce")
    lsbCondiments.Items.Add("Olives")
    lsbCondiments.Items.Add("Mayo")
    lsbCondiments.Items.Add("Tomatoes")
    lsbCondiments.Items.Add("American Cheese")
    lsbCondiments.Items.Add("Swiss Cheese")
    lsbCondiments.Items.Add("Salsa")
    lsbCondiments.Items.Add("Dump The Garden")

    lsbBreadType.Items.Add("White Bread Bun")    ' Rodzaje pieczywa
    lsbBreadType.Items.Add("Rye Bread Bun")
    lsbBreadType.Items.Add("Kaiser Roll")
    lsbBreadType.Items.Add("Bagel")
    lsbBreadType.Items.Add("Sour Dough")
    lsbBreadType.Items.Add("French Bread")
    lsbBreadType.SelectedIndex = 0

    rbnToasted.Checked = True
    lsbBreadType.Cursor = Cursors.Hand

  End Sub

  Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As _
                  System.EventArgs) Handles btnCheck.Click
    Dim i As Integer
    Dim LastOne As String
    Dim buff As String
    buff = ""
    txtOrder.Clear()  ' Czyścimy stare zamówienie 

    ' Budujemy nowe zamówienie
    txtOrder.AppendText(txtCustomer.Text)      ' Nazwa klienta
    txtOrder.AppendText(" ordered a ")
    txtOrder.AppendText(cmbSandwich.SelectedItem)  ' kanapka
    txtOrder.AppendText(" on a")
    If rbnToasted.Checked = True Then        ' wypieczona
      LastOne = " toasted "
    Else
      LastOne = " plain "
    End If
    txtOrder.AppendText(LastOne)
    txtOrder.AppendText(lsbBreadType.SelectedItem) ' Rodzaj pieczywa
    txtOrder.AppendText(" with ")

    For i = 0 To lsbCondiments.Items.Count - 1   ' Dodatki
      If lsbCondiments.GetSelected(i) = True Then
        LastOne = lsbCondiments.Items(i)
        buff &= LastOne & ", "
      End If
    Next
    i = InStr(buff, LastOne)     ' Zmieniamy ostatni przecinek na kropkę  
    If (i) Then
      buff = Microsoft.VisualBasic.Left(buff, i - 1) & " and " & _
                LastOne & "."
    End If

    txtOrder.AppendText(buff)     ' Wyświetla zamówienie

  End Sub

  Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As _
                 System.EventArgs) Handles btnExit.Click
    Me.Dispose()
  End Sub

  Private Sub txtCustomer_Leave(ByVal sender As Object, ByVal e As _
                   System.EventArgs) Handles txtCustomer.Leave
    cmbSandwich.DroppedDown = True  ' Pokazuje wszystkie opcje
    Me.Cursor = Cursors.Arrow  ' Ustawia typ bieżącego kusora 
  End Sub

End Class
