Question Locked

Visual Basic Nightmare: Need Yes/No ComboBox Help Please (Have a deadline)

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a deadline today and have been working on this for a LONG time, please help....

I have created a simple form for a brief survey. In this survey the user is asked 3 Yes/No questions in addition to 8 others where they input numbers for answers. At the end of the form the user presses a button to calculate their totals. (It won't calculate.)

I have it almost right but when I debug, it does not calculate. (I get a error:
Conversion from "Yes" to type 'double' is not valid) and than it highlights my combobox code in yellow

---------------------------------------------
'Convert combo box data to variables
typicallyPurchasedFoodAndBeverages = typicallyPurchasedFoodAndBeveragesCombobox.Text
typicallyPurchasedTShirt = typicallyPurchasedTShirtCombobox.Text
typicallyPurchasedCDAtHeadlinerConcertsOrMusicals = typicallyPurchasedCDAtHeadlinerConcertsOrMusicalsCombobox.Text

'Calculate the total cost of T-shirts
If typicallyPurchasedTShirt = Yes Then
totalCostOfTShirts = totalNumberOfHeadlinerConcertsAndMusicalsAndSportsGamesAttended * 20
Else
totalCostOfTShirts = 0
End If

'Calculate totalCostOfCDs
If typicallyPurchasedCDAtHeadlinerConcertsOrMusicals = Yes Then
totalCostOfCDs = totalNumberOfHeadlinerConcertsAndMusicalsAttended * 15
Else
totalCostOfCDs = 0
End If

If typicallyPurchasedFoodAndBeverages = Yes Then
totalCostOfFoodAndBeverages = totalNumberOfEventsAttended * 6
Else
totalCostOfFoodAndBeverages = 0
End If
---------------------------------------------
Example of Questions:
How many times have you attended a play at a local Community College? <>

Do you typically purchase a T-shirt when you attend a concert, musical or sports game? <>
if they answer yes than the number of events they have attended that sell T-shirts is multiplied by the cost of T-shirts to be added to the calculation

4 replies

by scott_heath

Whch version of VB are you using?

In any case the line:

If typicallyPurchasedTShirt = Yes Then...

Should be:

If typicallyPurchasedTShirt = "Yes" Then...

Since the contents of the {object}.text property is a string.

by tony hopkinson

but I'd say one of your typicallypurchased.... variables is a double as opposed to a string.

by mazvarirap

Why not sustitute the combobox with just a pop up screen to make it easy ?

This discussion is closed to new replies.