1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with using two inputs to one output

Discussion in 'C' started by petrina1, Jan 29, 2011.

  1. petrina1

    petrina1 New Member

    Joined:
    Jan 29, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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")
     
  2. poornaMoksha

    poornaMoksha New Member

    Joined:
    Jan 29, 2011
    Messages:
    150
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Software developer
    Location:
    India
    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....
     
  3. pein87

    pein87 New Member

    Joined:
    Aug 6, 2010
    Messages:
    173
    Likes Received:
    47
    Trophy Points:
    0
    Occupation:
    Web Dev
    Location:
    Limbo
    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.
     
    shabbir likes this.
  4. seoabhisek

    seoabhisek Banned

    Joined:
    Jan 22, 2011
    Messages:
    24
    Likes Received:
    1
    Trophy Points:
    0
    thanks for the information shared with us
     

Share This Page