quick question about add the cost of the items

beepstreet

Member
Joined
Oct 22, 2007
Messages
7
Programming Experience
Beginner
Im new to vb and just needed abit of help with this question i have been given.

Its about writing a program that consists of items that are priced at Glass-2, Plate-4, Table-12 and how many are sold each week.

Ive done the how many they sell each week
TotalWeek = (Glass+Plate+Table)
txtTotalWeek.Text = CStr(Totalweek)

So when i type in my textboxes by Glass,Plate,Table it adds up how many that have been sold for the week.

But how do i add the cost of the items in relation to how many ive sold?

Thanks!
 
if the prices are fixed you declare them in code

i.e.

VB.NET:
dim priceGlass as decimal = 1.99

then you multiply the number of Glasses by the price
 
VB.NET:
Dim breakfast As Double
        Dim glass As Double
        Dim plate As Double
        Dim table As Double

        glass = InputBox("Enter glass Amount")
        txtglasstotal.Text = glass


        plate= InputBox("Enter plate Amount")
        Txtplatetotal.Text = plate


        table = InputBox("Enter table Amount")
        txttabletotal.Text = table
i figured out that i had to use input boxes. so the input boxes show the quantity.
where do i put the prices here? so that it also adds the prices and the quantity?
 
Last edited by a moderator:
try this. inputboxes aren't your only option. there are a lot of ways you could do this

VB.NET:
Dim glassPrice As Double = 0.99
Dim platePrice As Double = 3.99
Dim tablePrice As Double = 2.00

Dim breakfast As Double
Dim glass As Double
Dim plate As Double
Dim table As Double

glass = InputBox("Enter glass Amount")
txtglasstotal.Text = ctype(glass * glassPrice, string)


plate= InputBox("Enter plate Amount")
Txtplatetotal.Text = ctype(plate * platePrice, string)
 


table = InputBox("Enter table Amount")
txttabletotal.Text = ctype(table * tablePrice, string)
 
Back
Top