Can anyone tell me why I am not able to select 2 Radio Buttons at the same time. In this program I am suppose to select a doughnut and a coffee choice but when I run the program I can only select a doughnut OR a coffee but not one of each. And if no selection is made I am suppose to see a message box. Here is my code. Any help is greatly appreciated.
Public Class frmMain
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
' Private Sub decSubtotal_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles btnDisplay.KeyPress
' allows the text box to accept numbers, the period, and the Backspace key
' If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back Then
' e.Handled = True
' End If
' End Sub
Private Sub Clearlabels()
' removes the contents from the labels that display subtotal, tax, and total due
txtSubtotal.Text = String.Empty
txtSalesTax.Text = String.Empty
txtTotal.Text = String.Empty
End Sub
Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
' displays the cost of donuts and coffee
Dim decSubtotal As Decimal
Dim decSalestax As Decimal
Dim decTaxRate As Decimal = 0.05D
Dim decTotal As Decimal
Clearlabels()
Dim noDonut As Boolean = False
' Calculates the cost of donuts
Select Case True
Case radGlazed.Checked OrElse radSugar.Checked
decSubtotal += 0.65D
Case radChocolate.Checked
decSubtotal += 0.85D
Case radFilled.Checked
decSubtotal += 1.8D
End Select
' add additional coffee charges
If radNone.Checked = True Then
'do nothing
ElseIf radRegular.Checked = True Then
decSubtotal += 1.8D
ElseIf radCappuccino.Checked = True Then
decSubtotal+= 2.5D
Else
MessageBox.Show("Please select Donut and Coffee Choices", _
"The Doughnut Shoppe", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If
'Compute the sales tax.
decSalestax = decTaxRate * decSubtotal
'Compute the total.
decTotal = decSubtotal + decSalestax
' determine the price of a donut and coffee
txtSubtotal.Text = decSubtotal.ToString("C2")
txtSalesTax.Text = decSalestax.ToString("C2")
txtTotal.Text = decTotal.ToString("C2")
End Sub
End Class
Public Class frmMain
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
' Private Sub decSubtotal_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles btnDisplay.KeyPress
' allows the text box to accept numbers, the period, and the Backspace key
' If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back Then
' e.Handled = True
' End If
' End Sub
Private Sub Clearlabels()
' removes the contents from the labels that display subtotal, tax, and total due
txtSubtotal.Text = String.Empty
txtSalesTax.Text = String.Empty
txtTotal.Text = String.Empty
End Sub
Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
' displays the cost of donuts and coffee
Dim decSubtotal As Decimal
Dim decSalestax As Decimal
Dim decTaxRate As Decimal = 0.05D
Dim decTotal As Decimal
Clearlabels()
Dim noDonut As Boolean = False
' Calculates the cost of donuts
Select Case True
Case radGlazed.Checked OrElse radSugar.Checked
decSubtotal += 0.65D
Case radChocolate.Checked
decSubtotal += 0.85D
Case radFilled.Checked
decSubtotal += 1.8D
End Select
' add additional coffee charges
If radNone.Checked = True Then
'do nothing
ElseIf radRegular.Checked = True Then
decSubtotal += 1.8D
ElseIf radCappuccino.Checked = True Then
decSubtotal+= 2.5D
Else
MessageBox.Show("Please select Donut and Coffee Choices", _
"The Doughnut Shoppe", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If
'Compute the sales tax.
decSalestax = decTaxRate * decSubtotal
'Compute the total.
decTotal = decSubtotal + decSalestax
' determine the price of a donut and coffee
txtSubtotal.Text = decSubtotal.ToString("C2")
txtSalesTax.Text = decSalestax.ToString("C2")
txtTotal.Text = decTotal.ToString("C2")
End Sub
End Class