'Radio Choice Selection
        Console.WriteLine("Please enter the Radio Choice for your vehicle: ")
        Console.WriteLine("Enter 1 for AM/FM Radio")
        Console.WriteLine("Enter 2 for AM/FM/CD/DVD")
        strRadioChoice = Console.ReadLine()
        Select Case strRadioChoice
            Case "1"
                Console.WriteLine("Price : $100")

            Case "2"
                Console.WriteLine("Price : $400")

            Case Else
                Console.WriteLine("Invalid selection")

        End Select

        SellingPrice = BasePrice + strEngineChoice + strInteriorChoice + strRadioChoice + ShippingCharge + DealerCharge
        Console.WriteLine("The total selling price for your vehicle is $" + SellingPrice)
        Console.WriteLine()
        Console.WriteLine("Press Enter to Exit")
        Console.ReadLine()

Recommended Answers

All 9 Replies

You need to be storing these individual values into numeric variables to be calculated at the end.

'Radio Choice
Selection

Dim decRadioPrice As Decimal

        Console.WriteLine("Please enter the Radio Choice for your vehicle: ")
        Console.WriteLine("Enter 1 for AM/FM Radio")
        Console.WriteLine("Enter 2 for AM/FM/CD/DVD")
        strRadioChoice = Console.ReadLine()
        Select Case strRadioChoice
            Case "1"
                Console.WriteLine("Price : $100")
                decRadioPrice = 100.00
            Case "2"
                Console.WriteLine("Price : $400")
                 decRadioPrice = 400.00
            Case Else
                Console.WriteLine("Invalid selection")

        End Select

        'SellingPrice = BasePrice + strEngineChoice + strInteriorChoice 
        '+ strRadioChoice + ShippingCharge + DealerCharge
 
         decTotal = decBasePrice + desEnginePrice + decInterior + decRadio etc
        Console.WriteLine("The total selling price for your vehicle is $" + FormatCurrencty(decTotal))
        Console.WriteLine()
        Console.WriteLine("Press Enter to Exit")
        Console.ReadLine()
commented: thanks this solved it! +1

Or you can use Integer.Parse() (or Double.Parse(), etc) at that line where you add all the numbers. Maybe add some exception around it, too, .Parse() is pretty picky and throws exceptions when it doesn't get what it wants.

commented: thank you for your help! +1

You should use integer.TryParse() or decimal.TryParse() instead of handling the exception. Throwing exceptions is a very expensive process and if you have exceptions being thrown in calculations (where it can occur over and over in loops) it can bring a system to a halt depending on the amount of data.

commented: thank you +1

TryParse is much better than Parse (unless you want exceptions I suppose) . My current job is in .Net 1.1, and I don't get to use TryParse, so I forgot about it. Yes, I do cry a little inside.

Or you can use Integer.Parse() (or Double.Parse(), etc) at that line where you add all the numbers. Maybe add some exception around it, too, .Parse() is pretty picky and throws exceptions when it doesn't get what it wants.

mikiurban are you saying to do decTotal = decBasePrice + decEnginePrice + decInterior + decRadio + decShippingCharge + decDealerCharge
Console.WriteLine("The total selling price for your vehicle is $" + Integer.Parse(decTotal))
I tried integer.parse() and parse.() neither worked

You should use integer.TryParse() or decimal.TryParse() instead of handling the exception. Throwing exceptions is a very expensive process and if you have exceptions being thrown in calculations (where it can occur over and over in loops) it can bring a system to a halt depending on the amount of data.

sknake i tried that and its saying "overload resolution failed because no accessible 'TryParse' accepts this number of arguments

Cast with the "CInt" function

commented: thank you +1

Cast with the "CInt" function

jbennet i'm new to programming and what am i supposed to do with "CInt"???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.