Hi fellas
my question is :::
Write a program to place an order from the restaurant menu below. Create the form and write the program so that after the button is clicked, the cost of the meal is calculated. The user must choose a Burger, but does not have to choose Fries and/or a Drink. Your program must deal with the possibility that the user does not choose one or both. It must also contain a "Reset Form" button that resets all the radio buttons on the form so that none of them are selected and clears any text in the textbox.
my code:
Public Class frmMenu
?
Private Sub grpChoiceBurgers_Enter(sender As Object, e As EventArgs) Handles grpChoiceBurgers.Enter
If grpChoiceBurgers.Enabled Then
?
grpFries.Enabled = True
grpChoiceDrink.Enabled = True
End If
?
End Sub
Private Sub grpFries_Enter(sender As Object, e As EventArgs) Handles grpFries.Enter
If grpFries.Enabled = True Then
grpChoiceDrink.Enabled = False
End If
End Sub
Private Sub grpChoiceDrink_Enter(sender As Object, e As EventArgs) Handles grpChoiceDrink.Enter
If grpChoiceDrink.Enabled = True Then
grpFries.Enabled = False
End If
End Sub
PS. no Checkboxes are to be used in this assignment only radiobuttons.
CHECK THE ATTACHMENT THE LOOK OF GUI ATTACHED
Loading

VulpesPosted Nov 23, 2013, 6:30 PM
You need to use panels rather than group boxes here if that in fact is what grpChoiceBurgers, grpFries etc are.
I've done this very quickly and so didn't have time to give the radiobuttons, labels and the (very small) panels used to produce square symbols sensible names but I've included the designer code so you can see what names I've actually used.
Public Class frmMenu
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
If Not RadioButton1.Checked AndAlso Not RadioButton2.Checked AndAlso Not RadioButton3.Checked AndAlso Not RadioButton4.Checked Then
MessageBox.Show("You must choose a burger")
Return
End If
Dim cost As Decimal = 0
If RadioButton1.Checked Then
cost = 4.19
ElseIf RadioButton2.Checked OrElse RadioButton3.Checked Then
cost = 4.79
Else
cost = 5.39
End If
If RadioButton5.Checked Then
cost += 2.39
ElseIf RadioButton6.Checked Then
cost += 3.09
ElseIf RadioButton7.Checked Then
cost += 4.99
End If
If RadioButton8.Checked Then
cost += 1.69
ElseIf RadioButton9.Checked Then
cost += 1.49
End If
txtCost.Text = cost.ToString("F2")
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
RadioButton5.Checked = False
RadioButton6.Checked = False
RadioButton7.Checked = False
RadioButton8.Checked = False
RadioButton9.Checked = False
txtCost.Text = ""
End Sub
End Class
' designer code
Partial Class frmMenu
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Private Sub InitializeComponent()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.Panel2 = New System.Windows.Forms.Panel()
Me.Panel3 = New System.Windows.Forms.Panel()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.pnlBurgers = New System.Windows.Forms.Panel()
Me.RadioButton1 = New System.Windows.Forms.RadioButton()
Me.RadioButton2 = New System.Windows.Forms.RadioButton()
Me.RadioButton3 = New System.Windows.Forms.RadioButton()
Me.RadioButton4 = New System.Windows.Forms.RadioButton()
Me.pnlFries = New System.Windows.Forms.Panel()
Me.RadioButton5 = New System.Windows.Forms.RadioButton()
Me.RadioButton6 = New System.Windows.Forms.RadioButton()
Me.RadioButton7 = New System.Windows.Forms.RadioButton()
Me.pnlDrinks = New System.Windows.Forms.Panel()
Me.RadioButton8 = New System.Windows.Forms.RadioButton()
Me.RadioButton9 = New System.Windows.Forms.RadioButton()
Me.Label4 = New System.Windows.Forms.Label()
Me.txtCost = New System.Windows.Forms.TextBox()
Me.btnCompute = New System.Windows.Forms.Button()
Me.btnReset = New System.Windows.Forms.Button()
Me.Label5 = New System.Windows.Forms.Label()
Me.Label6 = New System.Windows.Forms.Label()
Me.Label7 = New System.Windows.Forms.Label()
Me.pnlBurgers.SuspendLayout()
Me.pnlFries.SuspendLayout()
Me.pnlDrinks.SuspendLayout()
Me.SuspendLayout()
'
'Panel1
'
Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Panel1.Location = New System.Drawing.Point(21, 69)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(14, 15)
Me.Panel1.TabIndex = 0
'
'Panel2
'
Me.Panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Panel2.Location = New System.Drawing.Point(21, 257)
Me.Panel2.Name = "Panel2"
Me.Panel2.Size = New System.Drawing.Size(14, 15)
Me.Panel2.TabIndex = 1
'
'Panel3
'
Me.Panel3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Panel3.Location = New System.Drawing.Point(21, 367)
Me.Panel3.Name = "Panel3"
Me.Panel3.Size = New System.Drawing.Size(14, 15)
Me.Panel3.TabIndex = 2
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(55, 69)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(43, 13)
Me.Label1.TabIndex = 3
Me.Label1.Text = "Burgers"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(63, 257)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(29, 13)
Me.Label2.TabIndex = 4
Me.Label2.Text = "Fries"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(61, 367)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(37, 13)
Me.Label3.TabIndex = 5
Me.Label3.Text = "Drinks"
'
'pnlBurgers
'
Me.pnlBurgers.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.pnlBurgers.Controls.Add(Me.RadioButton4)
Me.pnlBurgers.Controls.Add(Me.RadioButton3)
Me.pnlBurgers.Controls.Add(Me.RadioButton2)
Me.pnlBurgers.Controls.Add(Me.RadioButton1)
Me.pnlBurgers.Location = New System.Drawing.Point(127, 25)
Me.pnlBurgers.Name = "pnlBurgers"
Me.pnlBurgers.Size = New System.Drawing.Size(200, 138)
Me.pnlBurgers.TabIndex = 6
'
'RadioButton1
'
Me.RadioButton1.AutoSize = True
Me.RadioButton1.Location = New System.Drawing.Point(15, 19)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.Size = New System.Drawing.Size(92, 17)
Me.RadioButton1.TabIndex = 7
Me.RadioButton1.TabStop = True
Me.RadioButton1.Text = "Regular (4.19)"
Me.RadioButton1.UseVisualStyleBackColor = True
'
'RadioButton2
'
Me.RadioButton2.AutoSize = True
Me.RadioButton2.Location = New System.Drawing.Point(15, 44)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.Size = New System.Drawing.Size(103, 17)
Me.RadioButton2.TabIndex = 8
Me.RadioButton2.TabStop = True
Me.RadioButton2.Text = "w/cheese (4.79)"
Me.RadioButton2.UseVisualStyleBackColor = True
'
'RadioButton3
'
Me.RadioButton3.AutoSize = True
Me.RadioButton3.Location = New System.Drawing.Point(15, 74)
Me.RadioButton3.Name = "RadioButton3"
Me.RadioButton3.Size = New System.Drawing.Size(98, 17)
Me.RadioButton3.TabIndex = 9
Me.RadioButton3.TabStop = True
Me.RadioButton3.Text = "w/bacon (4.79)"
Me.RadioButton3.UseVisualStyleBackColor = True
'
'RadioButton4
'
Me.RadioButton4.AutoSize = True
Me.RadioButton4.Location = New System.Drawing.Point(15, 103)
Me.RadioButton4.Name = "RadioButton4"
Me.RadioButton4.Size = New System.Drawing.Size(157, 17)
Me.RadioButton4.TabIndex = 10
Me.RadioButton4.TabStop = True
Me.RadioButton4.Text = "w/bacon and cheese (5.39)"
Me.RadioButton4.UseVisualStyleBackColor = True
'
'pnlFries
'
Me.pnlFries.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.pnlFries.Controls.Add(Me.RadioButton7)
Me.pnlFries.Controls.Add(Me.RadioButton6)
Me.pnlFries.Controls.Add(Me.RadioButton5)
Me.pnlFries.Location = New System.Drawing.Point(127, 203)
Me.pnlFries.Name = "pnlFries"
Me.pnlFries.Size = New System.Drawing.Size(200, 93)
Me.pnlFries.TabIndex = 7
'
'RadioButton5
'
Me.RadioButton5.AutoSize = True
Me.RadioButton5.Location = New System.Drawing.Point(15, 30)
Me.RadioButton5.Name = "RadioButton5"
Me.RadioButton5.Size = New System.Drawing.Size(80, 17)
Me.RadioButton5.TabIndex = 0
Me.RadioButton5.TabStop = True
Me.RadioButton5.Text = "Small (2.39)"
Me.RadioButton5.UseVisualStyleBackColor = True
'
'RadioButton6
'
Me.RadioButton6.AutoSize = True
Me.RadioButton6.Location = New System.Drawing.Point(15, 53)
Me.RadioButton6.Name = "RadioButton6"
Me.RadioButton6.Size = New System.Drawing.Size(92, 17)
Me.RadioButton6.TabIndex = 1
Me.RadioButton6.TabStop = True
Me.RadioButton6.Text = "Medium (3.09)"
Me.RadioButton6.UseVisualStyleBackColor = True
'
'RadioButton7
'
Me.RadioButton7.AutoSize = True
Me.RadioButton7.Location = New System.Drawing.Point(13, 93)
Me.RadioButton7.Name = "RadioButton7"
Me.RadioButton7.Size = New System.Drawing.Size(82, 17)
Me.RadioButton7.TabIndex = 2
Me.RadioButton7.TabStop = True
Me.RadioButton7.Text = "Large (4.99)"
Me.RadioButton7.UseVisualStyleBackColor = True
'
'pnlDrinks
'
Me.pnlDrinks.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.pnlDrinks.Controls.Add(Me.RadioButton9)
Me.pnlDrinks.Controls.Add(Me.RadioButton8)
Me.pnlDrinks.Location = New System.Drawing.Point(127, 322)
Me.pnlDrinks.Name = "pnlDrinks"
Me.pnlDrinks.Size = New System.Drawing.Size(200, 87)
Me.pnlDrinks.TabIndex = 8
'
'RadioButton8
'
Me.RadioButton8.AutoSize = True
Me.RadioButton8.Location = New System.Drawing.Point(15, 21)
Me.RadioButton8.Name = "RadioButton8"
Me.RadioButton8.Size = New System.Drawing.Size(80, 17)
Me.RadioButton8.TabIndex = 3
Me.RadioButton8.TabStop = True
Me.RadioButton8.Text = "Soda (1.69)"
Me.RadioButton8.UseVisualStyleBackColor = True
'
'RadioButton9
'
Me.RadioButton9.AutoSize = True
Me.RadioButton9.Location = New System.Drawing.Point(15, 47)
Me.RadioButton9.Name = "RadioButton9"
Me.RadioButton9.Size = New System.Drawing.Size(120, 17)
Me.RadioButton9.TabIndex = 4
Me.RadioButton9.TabStop = True
Me.RadioButton9.Text = "Bottled Water (1.49)"
Me.RadioButton9.UseVisualStyleBackColor = True
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(345, 372)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(74, 13)
Me.Label4.TabIndex = 9
Me.Label4.Text = "Cost of meal : "
'
'txtCost
'
Me.txtCost.Location = New System.Drawing.Point(438, 367)
Me.txtCost.Name = "txtCost"
Me.txtCost.Size = New System.Drawing.Size(100, 20)
Me.txtCost.TabIndex = 10
'
'btnCompute
'
Me.btnCompute.Location = New System.Drawing.Point(403, 300)
Me.btnCompute.Name = "btnCompute"
Me.btnCompute.Size = New System.Drawing.Size(87, 40)
Me.btnCompute.TabIndex = 11
Me.btnCompute.Text = "Compute cost of meal"
Me.btnCompute.UseVisualStyleBackColor = True
'
'btnReset
'
Me.btnReset.Location = New System.Drawing.Point(403, 61)
Me.btnReset.Name = "btnReset"
Me.btnReset.Size = New System.Drawing.Size(75, 23)
Me.btnReset.TabIndex = 12
Me.btnReset.Text = "Reset Form"
Me.btnReset.UseVisualStyleBackColor = True
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(146, 19)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(99, 13)
Me.Label5.TabIndex = 13
Me.Label5.Text = "Choices for Burgers"
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(160, 198)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(85, 13)
Me.Label6.TabIndex = 14
Me.Label6.Text = "Choices for Fries"
'
'Label7
'
Me.Label7.AutoSize = True
Me.Label7.Location = New System.Drawing.Point(160, 314)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(93, 13)
Me.Label7.TabIndex = 3
Me.Label7.Text = "Choices for Drinks"
'
'frmMenu
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(550, 448)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.btnReset)
Me.Controls.Add(Me.btnCompute)
Me.Controls.Add(Me.txtCost)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.pnlDrinks)
Me.Controls.Add(Me.pnlFries)
Me.Controls.Add(Me.pnlBurgers)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Panel3)
Me.Controls.Add(Me.Panel2)
Me.Controls.Add(Me.Panel1)
Me.Name = "frmMenu"
Me.Text = "Menu"
Me.pnlBurgers.ResumeLayout(False)
Me.pnlBurgers.PerformLayout()
Me.pnlFries.ResumeLayout(False)
Me.pnlFries.PerformLayout()
Me.pnlDrinks.ResumeLayout(False)
Me.pnlDrinks.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents Panel2 As System.Windows.Forms.Panel
Friend WithEvents Panel3 As System.Windows.Forms.Panel
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents pnlBurgers As System.Windows.Forms.Panel
Friend WithEvents RadioButton4 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents pnlFries As System.Windows.Forms.Panel
Friend WithEvents RadioButton7 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton6 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton5 As System.Windows.Forms.RadioButton
Friend WithEvents pnlDrinks As System.Windows.Forms.Panel
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents RadioButton9 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton8 As System.Windows.Forms.RadioButton
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents txtCost As System.Windows.Forms.TextBox
Friend WithEvents btnCompute As System.Windows.Forms.Button
Friend WithEvents btnReset As System.Windows.Forms.Button
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
End Class