Trying to learn VB.net easy question, maybe

M

Mike

Hey guys trying to learn VB.net. Taking a class and we are working on a
project. I think I might be trying to work farther ahead then I should. But
here is the situation.

I am writing a program to calc the size of a pizza along with toppings to go
on it. I have a combo box with 3 sizes and the price and 2 list boxes, one
with toppings that as you double-click on the item it moves it over to the
second list box.

For example "Medium $8.99"

And then a list box with 5 toppings that are sold for .99 cents each.

I have figured out how to initialize my combo box and list box as follows:

'Initialize combo box

cboSize.Text = "Pizza Size"
cboSize.Items.Add("Medium $8.99")
cboSize.Items.Add("Large $11.99")
cboSize.Items.Add("Gigantic $13.99")

'Initialize list box

lstChoices.Items.Add("Pepperoni")
lstChoices.Items.Add("Sausage")
lstChoices.Items.Add("Ham")
lstChoices.Items.Add("Onions")
lstChoices.Items.Add("Green Peppers")
lstChoices.Items.Add("Black Olives")


My problem is how do you take the item from the combobox turn it into and
integer? For example cboSize.Items.Add("Medium $8.99") = 8.99 Then take and
count the number of toppings from the listbox add them all together and
multiply it by .99 cents?

Not trying to cheat, just need a little help. I can't find anything in the
book up to the chapter we have covered so far that shows anything similar to
what I am trying to do.

Thanks for any help!

Mike
 
M

Michelle

Howdy

You can add them as ListItems instead of Strings, that will allow you
to specify both text and value.

i.e:

Dim item as New ListItem("Medium $8.99", "8.99")
cboSize.Items.Add(item)


Take care,
Michelle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top