How to add the results of a case

67 Views Asked by At

I am trying to display the results of this case and format the total amount in currency. However, It's not working and I am not quite sure why? Could someone please take a look at my code and tell me if you see what my eyes cannot. I just need a second pair of eyes on this one. Thank you!

Select Case ApplianceButton
        Case "Refrigerator"
            Label17.Text = FormatCurrency(kwVal).ToString
        Case "TV"
            Label19.Text = FormatCurrency(kwVal).ToString
        Case "Fan"
            Label21.Text = FormatCurrency(kwVal).ToString
        Case "Space Heater"
            Label23.Text = FormatCurrency(kwVal).ToString
        Case "Oven"
            Label25.Text = FormatCurrency(kwVal).ToString
        Case "Dryer"
            Label27.Text = FormatCurrency(kwVal).ToString
        Case "Laundry Washer"
            Label29.Text = FormatCurrency(kwVal).ToString

Label30.Text = Int((kwVal(Label17.Text) + kwVal(Label19.Text) 
    + kwVal(Label21.Text) + kwVal(Label23.Text) + kwVal(Label25.Text) 
    + kwVal(Label27.Text) + kwVal(Label29.Text)))
1

There are 1 best solutions below

0
On

The Appliancebutton should be the value that should display or provide the name of your appliances, then than makes Dim Appliancebutton as string ?

then if you say that your Appliance button was clicked or in any kind of event that happened, then the value of Appliancebutton= should be either "Refrigerator" or "TV" or "Fan" etc...

to use Formatcurrency function, then kwVal should be an integer or double etc... right?

and then on the grand total, the kwVal(Label17.Text), seems like you are trying to multiply kwVal and the Label17.Text...

your symbol should be an asterisk * and you can't possibly multiply a string and an integer, then if it would help, use Convert.toint32(label17.text), to complete the equation, though it may be long, I prefer kwVal*(Convert.toint32(label17.text) ?

Just making a guess... I don't know if this is right or helpful to you.