Help with using two inputs to one output

petrina1's Avatar, Join Date: Jan 2011
Newbie Member
Hello all I need some help badly ; i have been at this hours with no luck in solving my problem

I am doing a project in which i have two different costs of cookies (1 dollar for regular )and (1.50 for large). I am trying to get the user to be able to enter the amount of each cookie and it goes to one output(a label). I tried using the two codes below but they interfere with each other; only one works at a time. (either reg or large) curious how to get both working where i enter the amounts? PLEASE HELP
Dim input AsDecimal
input = Decimal.Parse(LargeCookieQtyTextbox.Text)
input = input * 1.5D
CookiesCostLabel.Text = input.ToString(
"c")

Dim inputinteger AsInteger 
inputinteger =
Integer.Parse(RegularCookieQtyTextbox.Text)
inputinteger = inputinteger * 1I
CookiesCostLabel.Text = inputinteger.ToString(
"C")
0
poornaMoksha's Avatar, Join Date: Jan 2011
Ambitious contributor
Not sure though, but seems like you are updating the same variable 'CookiesCostLabel.Text' independently for both type of cookies...which seems like getting overwritten with every new value assigned to it....
0
pein87's Avatar
Ambitious contributor
Are you parsing a file to get the value of the cookie? Why not use a database to store the value in to save you time or an xml file so it can be structured better. I personally have never used visual basic with xml or a database but I'm sure it would be better to structure the data that your using as input. Also get visual basic 2010 express its free and a IDE so it will warn you of your mistakes as you make them.

http://www.microsoft.com/express/Dow...0-Visual-Basic

Code: Visual Basic
Dim input AsDecimal
will not dimension a variable named input with the type decimal.

Code: Visual Basic
Dim input As Decimal
This is how you correctly dimension as variable with type

I suggest that you use just the numerical value instead of adding D(decimal) and I(int) at the end. Theres no need to add that since the variable has to fit the type its been cast as.
shabbir like this
0
seoabhisek's Avatar
Banned
thanks for the information shared with us