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 As Decimal input = Decimal.Parse(LargeCookieQtyTextbox.Text) input = input * 1.5D CookiesCostLabel.Text = input.ToString("c") Dim inputinteger As Integer inputinteger = Integer.Parse(RegularCookieQtyTextbox.Text) inputinteger = inputinteger * 1I CookiesCostLabel.Text = inputinteger.ToString("C")
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....
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/Downloads/#2010-Visual-Basic Code: Dim input AsDecimal will not dimension a variable named input with the type decimal. Code: 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.