Reputation:
Here's the image of my design interface:Design Interface
I want the user to make a selection and enter the quantity they wish to purchase then once they are done and press calculate, it gives the total of the items selected according to the quantity entered and inputs that total in the price textboxes.
Here's my code... I am stuck...
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Public Sub frmDrinks_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Public Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim tMango As Integer
Dim tOrange As Integer
Dim tStrawberry As Integer
Dim tWatermelon As Integer
Dim tMinty As Integer
Dim tCoke As Integer
Dim tDiet As Integer
Dim tSprite As Integer
Dim tMineral As Integer
Dim tSpark As Integer
Dim tManSmooth As Integer
Dim tBanSmooth As Integer
Dim tTropSmooth As Integer
Dim tStrawSmooth As Integer
Dim tVanilla As Integer
Dim tCookie As Integer
Dim tManShake As Integer
Dim tBanShake As Integer
tMango = txtMango.Text
tOrange = txtOrange.Text
tStrawberry = txtStrawberry.Text
tWatermelon = txtWatermelon.Text
tMinty = txtMinty.Text
tCoke = txtCoke.Text
tDiet = txtDiet.Text
tSprite = txtSprite.Text
tMineral = txtMineral.Text
tSpark = txtSparkling.Text
tManSmooth = txtMansmooth.Text
tBanSmooth = txtBanana.Text
tTropSmooth = txtTropical.Text
tStrawSmooth = txtStrawSmooth.Text
tVanilla = txtVanilla.Text
tCookie = txtChipCookie.Text
tManShake = txtManShake.Text
tBanShake = txtBanShake.Text
Dim TotalSum As Double = 0
If Me.chkJuices.Items().ToString = "Mango" Then
TotalSum += (100 * tMango)
End If
If Me.chkJuices.Items().ToString = "Orange" Then
TotalSum += (100 * tOrange)
End If
If Me.chkJuices.Items().ToString = "Strawberry" Then
TotalSum += (100 * tStrawberry)
End If
If Me.chkJuices.Items().ToString = "Watermelonade" Then
TotalSum += (100 * tWatermelon)
End If
If Me.chkJuices.Items().ToString = "Minty Pineade" Then
TotalSum += (100 * tMinty)
End If
txtJuice.Text = TotalSum
End Sub
Upvotes: 1
Views: 220
Reputation: 61
On the button click you will have to look after the checkboxes that are checked and then do the proper math
Private Sub Calculate() Handles Button.click
Dim TotalSum As Double = 0
For i = 0 To (CheckedListBox1.Items.Count - 1)
If CheckedListBox1.GetItemChecked(i) = True Then
If CheckedListBox1.Items(i).ToString = "Mango" Then
TotalSum += (100 * tMango)
End If
If CheckedListBox1.Items(i).ToString = "Orange" Then
TotalSum += (100 * tOrange)
End If
End If
Next
End Sub
Upvotes: 1