The UI is in the picture below.
Here is the code. If you want a ZIP let me know.
Public Class Form1
Private _orderNumber As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim oi = New OrderItem With {.Name = "Large", .Price = 4}
rbnLarge.Tag = oi
rbnLarge.Name = oi.Name
oi = New OrderItem With {.Name = "Medium", .Price = 3.25}
rbnMedium.Tag = oi
rbnMedium.Name = oi.Name
oi = New OrderItem With {.Name = "Small", .Price = 2.5}
rbnSmall.Tag = oi
rbnSmall.Name = oi.Name
Dim MeatOptions = {New OrderItem With {.Name = "Turkey", .Price = 0.6},
New OrderItem With {.Name = "Ham", .Price = 0.6},
New OrderItem With {.Name = "Roast Beef", .Price = 0.6}}
clbMeatOptions.Items.AddRange(MeatOptions)
Dim Fixings = {New OrderItem With {.Name = "Lettuce", .Price = 0.1},
New OrderItem With {.Name = "Tomato", .Price = 0.25},
New OrderItem With {.Name = "Mustard", .Price = 0.0},
New OrderItem With {.Name = "Onion", .Price = 0.1},
New OrderItem With {.Name = "Cheese", .Price = 0.5},
New OrderItem With {.Name = "Mayonnaise", .Price = 0.0}}
clbFixings.Items.AddRange(Fixings)
ResetInterface()
End Sub
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim Price As Double
If rbnLarge.Checked Then
Price = TryCast(rbnLarge.Tag, OrderItem).Price
ElseIf rbnMedium.Checked Then
Price = TryCast(rbnMedium.Tag, OrderItem).Price
ElseIf rbnSmall.Checked Then
Price = TryCast(rbnSmall.Tag, OrderItem).Price
End If
For Each item In clbMeatOptions.CheckedItems
Price += TryCast(item, OrderItem).Price
Next
For Each item In clbFixings.CheckedItems
Price += TryCast(item, OrderItem).Price
Next
txtSubTotal.Text = String.Format("${0:0.00}", Price)
Dim Tax As Double
Tax = Price * 0.079
txtTax.Text = String.Format("${0:0.00}", Tax)
txtTotal.Text = String.Format("${0:0.00}", Price + Tax)
_orderNumber += 1
lblOrderNumber.Text = String.Format("{0:D4}", _orderNumber)
MessageBox.Show("Please thank the customer for their business!!")
ResetInterface()
End Sub
Private Sub ResetInterface()
rbnMedium.Checked = True
ClearCLB(clbMeatOptions)
ClearCLB(clbFixings)
txtSubTotal.Text = ""
txtTax.Text = ""
txtTotal.Text = ""
lblOrderNumber.Text = ""
End Sub
Private Sub ClearCLB(clb As CheckedListBox)
For i As Integer = 0 To clb.Items.Count - 1
clb.SetItemChecked(i, False)
Next
clb.ClearSelected()
End Sub
End Class
Public Class OrderItem
Public Name As String
Public Price As Double
Public Overrides Function ToString() As String
Return Name
End Function
End Class