Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have tried to write this program and can not figure out these 3 errors and how to fix them. Can someone please help me. Her
VB
Public Class Form1                                                                                                     'Programmed by: Clifford May


    Private Sub btnCompute_Click(sender As System.Object, e As System.EventArgs) Handles btnCompute.Click



        ' This is where you decide what kind of burger you want.
        Dim sum As Double
        If chkBurgers.Checked Then
            Select Case radRegular
                      sum = 4.19
                Case radCheeseandBacon.Checked
                    sum = 4.79
                Case radBacon.Checked
                    sum = 4.79
                Case radCheeseandBacon.Checked
                    sum = 5.39


            End Select
        End If

        ' This is where you decide what size fries you want.
        If chkFries.Checked Then
            Select Case radSmall.Checked
            sum = 2.39
                Case radMedium.Checked
                    sum = 3.09
                Case radLarge.Checked
                    sum = 4.99


            End Select
        End If
        ' This is where you decide what drink you want.
        If chkDrinks.Checked Then
            Select Case radSoda.Checked
            sum = 1.69
                Case radBottleWater.Checked
                    sum = 1.49


            End Select
        End If
        Select Case btnCompute.Text = CStr(sum)





        End Select



    End Sub





    
End Class

i get 3 error listed that says Statements and labels are not valid between"Select Case ' and first 'Case.' on lines 12,27,39, column 23,13,131


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 29-Mar-12 21:16pm
v2

When you declare a Select Case statement block, the expression on the first line is compared against the values on the other lines:
VB
Select Case myInt
    Case 1
        DoSomethingForMyIntEqualOne()
        Exit Select
    Case 2
        DoSomethingForMyIntEqualTwo()
        Exit Select
End Select

What you appear to be doing is trying to use it as a bastardised if statement.
Try actually using If instead - it might help you to get started.
In addition, when you get the burger price selection working - you will overwrite it with the fries selection... Look at making an "item" price element, which you add onto the cost after each stage. So Burger would select "item" to be 0, 4.19, 4.79 or 5.39, which you add into sum, then Fries would select a different value into "item", and so on.
 
Share this answer
 
Your "Select" syntax is error. You missed expression xxx
VB
' This is where you decide what kind of burger you want.
        Dim sum As Double
        If chkBurgers.Checked Then
            Select Case radRegular
                Case xxx
                      sum = 4.19
                Case radCheeseandBacon.Checked
                    sum = 4.79
                Case radBacon.Checked
                    sum = 4.79
                Case radCheeseandBacon.Checked
                    sum = 5.39
            End Select
        End If
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900