Answered Reading from collection?

yngasctmagfi

New member
Joined
Dec 7, 2009
Messages
3
Programming Experience
Beginner
I am working on a small program that reads items from a text file. The items are the split up into data and used to fill the menuItem() as menuItems. Each instance of menuItem has 3 properties (name(string), price(double), and menuType(string)). As an item is selected, it's price is added to the Order collection with :

Order.Add(menuItem(index).price)

The running total of the sum of the selected items is to be displayed in text box. I have,
VB.NET:
txtTotal.Text = FormatCurrency(runningTotal())        [COLOR="Green"]' with runningTotal as a function[/COLOR]
[COLOR="Blue"]
Function[/COLOR] runningTotal()
        [COLOR="Blue"]For Each[/COLOR] menuItem [COLOR="Blue"]As[/COLOR] MenuItems [COLOR="Blue"]In[/COLOR] Order
            total += [COLOR="Blue"]CDbl[/COLOR](menuItem.price)
        [COLOR="Blue"]Next[/COLOR] menuItem
       [COLOR="Blue"] Return[/COLOR] total
    [COLOR="Blue"]End Function[/COLOR]

However, when run, this error appears. This is new coding to me, so if I'm just way off, let me know. Anywho, I tried with & without the CDbl. It doesn't seem to have any effect.

Oops.jpg
 
Last edited:
Accordingly "Order" contains the prices, not the menuitems.
 
Back
Top