Answer to Question #50771 in Visual Basic for Tom

Question #50771
I am making a resturant menu in visual basic/studio 2012. I am supposed to make the groups be visible and invisible if their checkboxes are checked or not. Also I cannot make it compute anything except the first group. This is the code I have made so far and the two errors I get: Public Class frmMenu Private Sub chkBurgers_CheckedChanged(sender As Object, e As EventArgs) Handles chkBurgers.CheckedChanged If chkBurgers.Checked Then grpBurgers.Visible = True Else grpBurgers.Visible = False End If End Sub Private Sub chkFries_CheckedChanged(sender As Object, e As EventArgs) Handles chkFries.CheckedChanged If chkFries.Checked Then grpFries.Visible = True Else grpFries.Visible = False End If End Sub Private Sub chkDrinks_CheckedChanged(sender As Object, e As EventArgs) Handles chkDrinks.CheckedChanged If chkDrinks.Checked Then grpDrinks.Visible = True Else grpDrinks.Visible = False End If End Sub Private Sub btnCompute_Click(sender As Object, e As EventArgs) Handles btnCompute.Click Dim sum As Double If chkBurgers.Checked Then If radRegular.Checked Then sum += 4.19 ElseIf radCheese.Checked Or radBacon.Checked Then sum += 4.79 ElseIf radBaconandCheese.Checked Then sum += 5.39 End If End If If chkFries.Checked Then If radSmall.Checked Then sum += 2.39 ElseIf radMedium.Checked Then sum += 3.09 ElseIf radLarge.Checked Then sum += 4.99 End If End If If chkDrinks Then If radSoda.Checked Then sum += 1.69 ElseIf radBottledWater Then sum += 1.49 End If End If txtCost.Text = sum.ToString("C") End Sub End Class Also I recieved two errors which are: 1 Value of type 'System.Windows.Forms.CheckBox' cannot be converted to 'Boolean'. C:\Vis2012\Resturant Menu\Resturant Menu\frmMenu.vb Resturant Menu 2 Value of type 'System.Windows.Forms.RadioButton' cannot be converted to 'Boolean'. C:\Vis2012\Resturant Menu\Resturant Menu\frmMenu.vb Resturant Menu
Expert's answer
Solution.
PublicClass frmMenu
Private Sub chkBurgers_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
HandleschkBurgers.CheckedChanged


IfchkBurgers.Checked Then
grpBurgers.Visible = True
Else
grpBurgers.Visible = False
End If
End Sub
Private Sub chkFries_CheckedChanged(ByValsender As Object,ByVal e As EventArgs) HandleschkFries.CheckedChanged

IfchkFries.Checked Then
grpFries.Visible = True
Else
grpFries.Visible = False
End If
End Sub
Private Sub chkDrinks_CheckedChanged(ByValsender As Object,ByVal e As EventArgs) HandleschkDrinks.CheckedChanged

IfchkDrinks.Checked Then
grpDrinks.Visible = True
Else
grpDrinks.Visible = False
End If
End Sub


Private Sub btnCompute_Click(ByValsender As Object,ByVal e As EventArgs) HandlesbtnCompute.Click
Dim sumAs Double

IfchkBurgers.Checked Then
IfradRegular.Checked Then
sum += 4.19
ElseIfradCheese.Checked Or radBacon.Checked Then
sum += 4.79
ElseIfradBaconandCheese.Checked Then
sum += 5.39
EndIf
End If

IfchkFries.Checked Then
IfradSmall.Checked Then
sum += 2.39
ElseIfradMedium.Checked Then
sum += 3.09
ElseIfradLarge.Checked Then
sum += 4.99
EndIf
End If


IfchkDrinks.Checked Then 'There was an error

IfradSoda.Checked Then
sum += 1.69
ElseIfradBottledWater.Checked Then 'There was an error

sum += 1.49
EndIf
End If
txtCost.Text = sum.ToString("C")
End Sub

EndClass

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS
paypal