ok so I want my program to avoid from crashing if the 'user' didn't check a certain thing, so I want to be able to click the add button without it crashing on me because you cannot select 'null'
Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles btnAdd.Click
'clear out grand total variable
'so if user changes mind it does not contain
'old values
total = 0
'as long as the variable contains something!
If Pizza <> "" Then
End If
' add up the decimal variables
'for a grand total price
total = total + PizzaPrice
total = total + Pizzas(0)
total = total + Pizzas(1)
total = total + Pizzas(2)
total = total + Pizzas(3)
total = total + Pizzas(4)
'clear the list box
'in case user changes
'items selected
TotalPrice.Items.Clear()
' add title
TotalPrice.Items.Add("Pizza Selected:--")
TotalPrice.Items.Add(Pizza)
For i As Integer = 0 To 4
Next
If Not Pizzas(i) = "" Then
TotalPrice.Items.Add(Pizzas(i))
End If
If TwoSizes <> "" Then
End If
total = total + SizesPrice
total = total + SizesTotalPrice(0)
total = total + SizesTotalPrice(1)
TotalPrice.Items.Add("Size Selected:--")
TotalPrice.Items.Add(TwoSizes)
For i As Integer = 0 To 1
If Not SizesTotalPrice(i) = "" Then
TotalPrice.Items.Add(SizesTotalPrice(i))
End If
Next
If base <> "" Then
total = total + baseprice
total = total + twobases(0)
total = total + twobases(1)
TotalPrice.Items.Add("Base Selected:--")
TotalPrice.Items.Add(base)
For i As Integer = 0 To 1
If Not twobases(i) = "" Then
TotalPrice.Items.Add(twobases(i))
End If
Next
total = total + drinkprice
total = total + twodrinks(0)
total = total + twodrinks(1)
total = total + twodrinks(2)
TotalPrice.Items.Add("Drink Selected:--")
TotalPrice.Items.Add(drink)
For i As Integer = 0 To 2
If Not twodrinks(i) = "" Then
TotalPrice.Items.Add(twodrinks(i))
End If
Next
total = total + toppingprice
total = total + toppingprice1
total = total + toppingprice2
total = total + toppingprice3
total = total + toppings(0)
total = total + toppings(1)
total = total + toppings(2)
total = total + toppings(3)
TotalPrice.Items.Add("Topping Selected:--")
TotalPrice.Items.Add(topping)
TotalPrice.Items.Add(topping1)
TotalPrice.Items.Add(topping2)
TotalPrice.Items.Add(topping3)
For i As Integer = 0 To 3
If Not toppings(i) = "" Then
TotalPrice.Items.Add(toppings(i))
End If
Next
'add a dotted line
TotalPrice.Items.Add("----------")
'etc etc
TotalPrice.Items.Add("Total £" & total)
None
0 Points
1 Post
value cannot be null parameter name: item
May 09, 2013 07:31 AM|grantify|LINK
ok so I want my program to avoid from crashing if the 'user' didn't check a certain thing, so I want to be able to click the add button without it crashing on me because you cannot select 'null'
Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles btnAdd.Click
'clear out grand total variable
'so if user changes mind it does not contain
'old values
total = 0
'as long as the variable contains something!
If Pizza <> "" Then
End If
' add up the decimal variables
'for a grand total price
total = total + PizzaPrice
total = total + Pizzas(0)
total = total + Pizzas(1)
total = total + Pizzas(2)
total = total + Pizzas(3)
total = total + Pizzas(4)
'clear the list box
'in case user changes
'items selected
TotalPrice.Items.Clear()
' add title
TotalPrice.Items.Add("Pizza Selected:--")
TotalPrice.Items.Add(Pizza)
For i As Integer = 0 To 4
Next
If Not Pizzas(i) = "" Then
TotalPrice.Items.Add(Pizzas(i))
End If
If TwoSizes <> "" Then
End If
total = total + SizesPrice
total = total + SizesTotalPrice(0)
total = total + SizesTotalPrice(1)
TotalPrice.Items.Add("Size Selected:--")
TotalPrice.Items.Add(TwoSizes)
For i As Integer = 0 To 1
If Not SizesTotalPrice(i) = "" Then
TotalPrice.Items.Add(SizesTotalPrice(i))
End If
Next
If base <> "" Then
total = total + baseprice
total = total + twobases(0)
total = total + twobases(1)
TotalPrice.Items.Add("Base Selected:--")
TotalPrice.Items.Add(base)
For i As Integer = 0 To 1
If Not twobases(i) = "" Then
TotalPrice.Items.Add(twobases(i))
End If
Next
total = total + drinkprice
total = total + twodrinks(0)
total = total + twodrinks(1)
total = total + twodrinks(2)
TotalPrice.Items.Add("Drink Selected:--")
TotalPrice.Items.Add(drink)
For i As Integer = 0 To 2
If Not twodrinks(i) = "" Then
TotalPrice.Items.Add(twodrinks(i))
End If
Next
total = total + toppingprice
total = total + toppingprice1
total = total + toppingprice2
total = total + toppingprice3
total = total + toppings(0)
total = total + toppings(1)
total = total + toppings(2)
total = total + toppings(3)
TotalPrice.Items.Add("Topping Selected:--")
TotalPrice.Items.Add(topping)
TotalPrice.Items.Add(topping1)
TotalPrice.Items.Add(topping2)
TotalPrice.Items.Add(topping3)
For i As Integer = 0 To 3
If Not toppings(i) = "" Then
TotalPrice.Items.Add(toppings(i))
End If
Next
'add a dotted line
TotalPrice.Items.Add("----------")
'etc etc
TotalPrice.Items.Add("Total £" & total)
End If
End Sub
All-Star
35149 Points
9075 Posts
Re: value cannot be null parameter name: item
May 09, 2013 01:30 PM|smirnov|LINK
Where do you get your error and how exactly its message looks like? There is no reference to "item" as mentioned in the title of your post.
The code is somehow strange and incomplete. For example,
then
and so on...