Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Help with using two inputs to one output (http://www.go4expert.com/forums/help-using-inputs-output-t24782/)

petrina1 29Jan2011 06:01

Help with using two inputs to one output
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(

Dim inputinteger AsInteger 
inputinteger =
inputinteger = inputinteger * 1I
CookiesCostLabel.Text = inputinteger.ToString(

poornaMoksha 31Jan2011 11:47

Re: Help with using two inputs to one output
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....

pein87 1Feb2011 09:02

Re: Help with using two inputs to one output
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.


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.

seoabhisek 1Feb2011 12:32

Re: Help with using two inputs to one output
thanks for the information shared with us

All times are GMT +5.5. The time now is 20:48.