pickslides
New member
- Joined
- Jul 11, 2019
- Messages
- 2
- Programming Experience
- 3-5
Hi all,
I have made a VB form for a pizza calculator
Users are to populate the size of pizza they want (Check Box 1, 2 &3) they can only click one
Which extra toppings they like (Combo Box 4, 5, 6 & 7- Multiple allowed)
Sides they want (Textbox 2, 3, 4) - enter a value
And a button to calculate the cost
For some reason the code does not always include all costs or parameters
Q
I have made a VB form for a pizza calculator
Users are to populate the size of pizza they want (Check Box 1, 2 &3) they can only click one
Which extra toppings they like (Combo Box 4, 5, 6 & 7- Multiple allowed)
Sides they want (Textbox 2, 3, 4) - enter a value
And a button to calculate the cost
For some reason the code does not always include all costs or parameters
Q
VB.NET:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim TotalCost As Double
TotalCost = 0
If CheckBox1.Checked Then TotalCost = TotalCost + 7
If CheckBox2.Checked Then TotalCost = TotalCost + 9
If CheckBox3.Checked Then TotalCost = TotalCost + 10
If CheckBox4.Checked Then TotalCost = TotalCost + 2
If CheckBox5.Checked Then TotalCost = TotalCost + 2
If CheckBox6.Checked Then TotalCost = TotalCost + 2
If CheckBox7.Checked Then TotalCost = TotalCost + 2
TotalCost = TotalCost + 2 * TextBox2.Text + 3 * TextBox3.Text + 5 * TextBox4.Text
TextBox1.Text = TotalCost
End Sub
End Class
Last edited by a moderator: