| You are here: DEVPPL ‹ Forum ‹ Programming ‹ Visual Basic Forum |
NOTIFICATIONS
|
|
|||||||||||||||
Login |
2 items in a combo box and a list box and help with total
2 posts
• Page 1 of 1
0
2 items in a combo box and a list box and help with total
hello i am pretty new to vb but on my form when i play it, it shows 2 of each item in a combo box and a list box. and for the total the prices wont add onto it properly. can someone help heres the code
- Code: Select all
Public Class Form1
Public total, type, pizzasize, toppings, extra As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CboSize.Items.Add("9'")
CboSize.Items.Add("11'")
CboSize.Items.Add("13'")
LstTop.Items.Add("mushroom")
LstTop.Items.Add("pepper")
LstTop.Items.Add("sweetcorn")
LstTop.Items.Add("ham")
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptMargherita.CheckedChanged
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If OptMargherita.Checked = True Then
type = 5
ElseIf OptPepperoni.Checked = True Then
type = 6
ElseIf OptMeatfeast.Checked = True Then
type = 7
End If
If CboSize.SelectedItem = "9'" Then
pizzasize = 2
ElseIf CboSize.SelectedItem = "11'" Then
pizzasize = 3
ElseIf CboSize.SelectedItem = "13'" Then
pizzasize = 3
End If
If LstTop.SelectedItem = "mushroom" Then
toppings = 2
ElseIf LstTop.SelectedItem = "pepper" Then
toppings = 2
ElseIf LstTop.SelectedItem = "sweetcorn" Then
toppings = 2
ElseIf LstTop.SelectedItem = "ham" Then
toppings = 2
End If
If LstBoxExtra.SelectedItem = "fanta" Then
extra = 1
ElseIf LstBoxExtra.SelectedItem = "pepsi" Then
extra = 1
ElseIf LstBoxExtra.SelectedItem = "coke" Then
extra = 1
ElseIf LstBoxExtra.SelectedItem = "sprite" Then
extra = 1
ElseIf LstBoxExtra.SelectedItem = "hot cookie" Then
extra = 2
ElseIf LstBoxExtra.SelectedItem = "ice cream" Then
extra = 1
ElseIf LstBoxExtra.SelectedItem = "cookie dough" Then
extra = 2
ElseIf LstBoxExtra.SelectedItem = "umbungo fruit salad" Then
extra = 2
End If
total = type + pizzasize + toppings + extra
txttotal.Text = Format((total), "currency")
End Sub
End Class
- Thayguy
- Reputation: 0
- Posts: 1
- Joined: Tue Nov 15, 2011 3:21 pm
- Highscores: 0
- Arcade winning challenges: 0
2 items in a combo box and a list box and help with total - Sponsored results
- Sponsored results
0
Re: 2 items in a combo box and a list box and help with total
you havent got items added to extra items o.0 i ran it without extra items with random things picked and it worked fine. Showed me 10£
Public Class Form1
Public total, type, pizzasize, toppings, extra As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CboSize.Items.Add("9'")
CboSize.Items.Add("11'")
CboSize.Items.Add("13'")
LstTop.Items.Add("mushroom")
LstTop.Items.Add("pepper")
LstTop.Items.Add("sweetcorn")
LstTop.Items.Add("ham")
lstBoxExtra.Items.Add("pepsi")
lstBoxExtra.Items.Add("fanta")
lstBoxExtra.Items.Add("coke")
lstBoxExtra.Items.Add("sprite")
lstBoxExtra.Items.Add("hot cookie")
lstBoxExtra.Items.Add("ice cream")
lstBoxExtra.Items.Add("cookie dough")
lstBoxExtra.Items.Add("umbungo fruit salad")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If OptMargherita.Checked = True Then
type = 5
ElseIf OptPepperoni.Checked = True Then
type = 6
ElseIf OptMeatfeast.Checked = True Then
type = 7
End If
If CboSize.SelectedItem = "9'" Then
pizzasize = 2
ElseIf CboSize.SelectedItem = "11'" Then
pizzasize = 3
ElseIf CboSize.SelectedItem = "13'" Then
pizzasize = 3
End If
If LstTop.SelectedItem = "mushroom" Then
toppings = 2
ElseIf LstTop.SelectedItem = "pepper" Then
toppings = 2
ElseIf LstTop.SelectedItem = "sweetcorn" Then
toppings = 2
ElseIf LstTop.SelectedItem = "ham" Then
toppings = 2
End If
If lstBoxExtra.SelectedItem = "fanta" Then
extra = 1
ElseIf lstBoxExtra.SelectedItem = "pepsi" Then
extra = 1
ElseIf lstBoxExtra.SelectedItem = "coke" Then
extra = 1
ElseIf lstBoxExtra.SelectedItem = "sprite" Then
extra = 1
ElseIf lstBoxExtra.SelectedItem = "hot cookie" Then
extra = 2
ElseIf lstBoxExtra.SelectedItem = "ice cream" Then
extra = 1
ElseIf lstBoxExtra.SelectedItem = "cookie dough" Then
extra = 2
ElseIf lstBoxExtra.SelectedItem = "umbungo fruit salad" Then
extra = 2
End If
total = type + pizzasize + toppings + extra
txttotal.Text = Format((total), "currency")
End Sub
End Class
Public Class Form1
Public total, type, pizzasize, toppings, extra As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CboSize.Items.Add("9'")
CboSize.Items.Add("11'")
CboSize.Items.Add("13'")
LstTop.Items.Add("mushroom")
LstTop.Items.Add("pepper")
LstTop.Items.Add("sweetcorn")
LstTop.Items.Add("ham")
lstBoxExtra.Items.Add("pepsi")
lstBoxExtra.Items.Add("fanta")
lstBoxExtra.Items.Add("coke")
lstBoxExtra.Items.Add("sprite")
lstBoxExtra.Items.Add("hot cookie")
lstBoxExtra.Items.Add("ice cream")
lstBoxExtra.Items.Add("cookie dough")
lstBoxExtra.Items.Add("umbungo fruit salad")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If OptMargherita.Checked = True Then
type = 5
ElseIf OptPepperoni.Checked = True Then
type = 6
ElseIf OptMeatfeast.Checked = True Then
type = 7
End If
If CboSize.SelectedItem = "9'" Then
pizzasize = 2
ElseIf CboSize.SelectedItem = "11'" Then
pizzasize = 3
ElseIf CboSize.SelectedItem = "13'" Then
pizzasize = 3
End If
If LstTop.SelectedItem = "mushroom" Then
toppings = 2
ElseIf LstTop.SelectedItem = "pepper" Then
toppings = 2
ElseIf LstTop.SelectedItem = "sweetcorn" Then
toppings = 2
ElseIf LstTop.SelectedItem = "ham" Then
toppings = 2
End If
If lstBoxExtra.SelectedItem = "fanta" Then
extra = 1
ElseIf lstBoxExtra.SelectedItem = "pepsi" Then
extra = 1
ElseIf lstBoxExtra.SelectedItem = "coke" Then
extra = 1
ElseIf lstBoxExtra.SelectedItem = "sprite" Then
extra = 1
ElseIf lstBoxExtra.SelectedItem = "hot cookie" Then
extra = 2
ElseIf lstBoxExtra.SelectedItem = "ice cream" Then
extra = 1
ElseIf lstBoxExtra.SelectedItem = "cookie dough" Then
extra = 2
ElseIf lstBoxExtra.SelectedItem = "umbungo fruit salad" Then
extra = 2
End If
total = type + pizzasize + toppings + extra
txttotal.Text = Format((total), "currency")
End Sub
End Class
- Ciiure
- Reputation: 1
- Posts: 5
- Joined: Fri Nov 18, 2011 8:45 pm
- Highscores: 0
- Arcade winning challenges: 0
|
|