im trying to add two radio buttons together to get a full price, they are split up by two group boxes. Meals and dormitories, I have the prices on how much they are, but I dont know how to put the right radio buttons in the right places and then add them up, here is the code I have so far

Public Class Form1
    Const decRadioButtonmichigan As Decimal = 1500.0 '  this is suppose to go in the dormitories group box
    Const decRadioButtoneagle As Decimal = 1600.0 ' this is suppose to go in the dormitories group box
    Const decRadioButtonhuron As Decimal = 1200.0 ' this is suppose to go in the dormitories group box
    Const decRadioButtonSuperior As Decimal = 1800.0 ' this is suppose to go in the dormitories group box
    Const decRadioButtonlunch As Decimal = 560.0 ' this is suppose to go in the meal group box
    Const decRadioButtondinner As Decimal = 1102.0 ' this is suppose to go in the meal group box
    Const decRadioButtonUnlimited As Decimal = 1500.0 ' this is suppose to go in the meal group box


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' this is to close the application
        Me.Close()
    End Sub

    Private Sub RadioButtonlunch_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonlunch.CheckedChanged

    End Sub

    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
        ' this is my dormitories group box
    End Sub

    Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox2.Enter
        ' this is my meal box
    End Sub
End Class

I still need an answer label, but I just dont know how to put the radio buttons that are suppose to go in the assigned group box and add one radio button from each group box to the other group box to produce an answer, basically how do I take one of the radio buttons from each of the two group boxes and add both of them up to produce an answer

Const r1 As Decimal = 1500.0 '  group box1
    Const r2 As Decimal = 1600.0 ' group box1
    Const r3 As Decimal = 1200.0 ' group box1
    Const r4 As Decimal = 1800.0 ' group box2
    Const r5 As Decimal = 560.0 ' group box2
    Const r6 As Decimal = 1102.0 ' group box2
   

    Dim s1 As Long = 0.0
    Dim s2 As Long = 0.0
    Dim sum As Long = 0.0

Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
        s2 = r4
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        s1 = r1
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        s1 = r2
    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        s1 = r3
    End Sub

    Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
        s2 = r5
    End Sub

    Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
        s2 = r6
    End Sub
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        sum = s1 + s2
    End Sub

here first 3 radio button is belongs to groupbox1 and next 3 radiobutton belongs to groupbox 2
Its an example not exactly what you want
I hope it will help you to solve your problem

I have no idea whats going on and theres a missing radio buton, one of the dormonitories is missing. I don’t understand the code because there is no marks on there explaining what is going on, could someone explain to me whats going on and what produces the answer?

Here I use two group box as you require just name is different in my case groupbox1 and groupbox2, I use six constant variable r1 to r6 which refers to value of radio button and three variable s1,s2 and sum.

Here what going on in my code when user select any radio button from groupbox1 value assign to s1 which refers to that radio button
For example when user select radio button 1
s1=r1
when select radio button2
s1=r2 so on
when change the selection from group box 1 it change the value according to that in s1.

similarly when user select any radiobutton in groupbox2 value assign to s2 which referring to that radio button
for example when user select radio button4
s2=r4

when user select radio button 5
s2=r5 son

now when user click on button
sum =s1+s2

that is add the value of two selected radio button and assign the value in sum

If still a bit confused, see if this helps.

Public Class Form1
    '//--- Dormitories GroupBox.
    Const dblDormMichigan As Double = 1500.0,dblDormEagle As Double = 1600.0
    Const dblDormHuron As Double = 1200.0,dblDormSuperior As Double = 1800.0
    '//--- Meals GroupBox.
    Const dblMealLunch As Double = 560.0, dblMealDinner As Double = 1102.0, dblMealUnlimited As Double = 1500.0
    '//--- Totals.
    Private dblDormTotal As Double = 0
    Private dblMealTotal As Double = 0

    '// Dormitories. GroupBox1
    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                                            Handles RadioButton1.CheckedChanged, RadioButton2.CheckedChanged, _
                                                       RadioButton3.CheckedChanged, RadioButton4.CheckedChanged
        If RadioButton1.Checked Then dblDormTotal = dblDormMichigan
        If RadioButton2.Checked Then dblDormTotal = dblDormEagle
        If RadioButton3.Checked Then dblDormTotal = dblDormHuron
        If RadioButton4.Checked Then dblDormTotal = dblDormSuperior
        Label1.Text = (dblDormTotal + dblMealTotal).ToString("c") '// add Total.
    End Sub
    '// Meals. GroupBox2
    Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                                            Handles RadioButton5.CheckedChanged, RadioButton6.CheckedChanged, RadioButton7.CheckedChanged
        If RadioButton5.Checked Then dblMealTotal = dblMealLunch
        If RadioButton6.Checked Then dblMealTotal = dblMealDinner
        If RadioButton7.Checked Then dblMealTotal = dblMealUnlimited
        Label1.Text = (dblDormTotal + dblMealTotal).ToString("c") '// add Total.
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RadioButton1.Checked = True : RadioButton5.Checked = True '// both GrouBoxes to have a selection made on .Load.
    End Sub
End Class

Im a beginner VB-er too, so I know what you're going through Rookanga. Im not sure what you mean by how to put the radio buttons in the groupbox (you can do it in design time, put a groupbox onto the form then drag the radio buttons into the group box. I did a project not so long ago similar to what you are doing now. The easiest way for me to deal with variables that I need in various sub routines is to change their scope and make them modular-level variables. This way when you make your radiobutton selections and click the (im assuming) 'Calculate' button, the event behind the calc button can pull the values from the radiobutton_clickchanged event. For ex. after the selection from the two groupboxes has been made, this would be the code for the calc button event:

Public Class Form1

'these variable must be friend-ed in order for this to work this way; the only way to be able to 'friend' this is in Mod-level

Friend dormSelection As Decimal
Friend mealSelection As Decimal
Friend totalCost As Decimal

 
    Private Sub michiganRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles michiganRadioButton.CheckedChanged

        dormSelected = 1500D

    End Sub

    Private Sub eagleRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles eagleRadioButton.CheckedChanged

        dormSelected = 1600D

    End Sub

    Private Sub huronRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles huronRadioButton.CheckedChanged

        dormSelected = 1200D

    End Sub

    Private Sub superiorRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles superiorRadioButton.CheckedChanged

        dormSelected = 1800D

    End Sub

    Private Sub lunchRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lunchRadioButton.CheckedChanged

        mealSelected = 560D

    End Sub

    Private Sub dinnerRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dinnerRadioButton.CheckedChanged

        mealSelected = 1102D

    End Sub

    Private Sub unlimitedRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles unlimitedRadioButton.CheckedChanged

        mealSelected = 1500D

    End Sub

    Private Sub calcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calcButton.Click

        totalSelectedAmount = mealSelected + dormSelected
        displayAmoutLabel.Text = FormatCurrency(CStr(totalSelectedAmount))

    End Sub
End Class



or

dormSelection = michiganRadioButton

That's how I did it, and it works beautifully. Only thing i didnt add was the exit, clear and print buttons.
Hope this helps.

PS. Disregard lines 63 through 65.

@e ayt

Const r1 As Decimal = 1500.0 ' group box1
Const r2 As Decimal = 1600.0 ' group box1
Const r3 As Decimal = 1200.0 ' group box1
Const r4 As Decimal = 1800.0 ' group box2
Const r5 As Decimal = 560.0 ' group box2
Const r6 As Decimal = 1102.0 ' group box2


Dim s1 As Long = 0.0
Dim s2 As Long = 0.0
Dim sum As Long = 0.0

Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
s2 = r4
End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
s1 = r1
End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
s1 = r2
End Sub

Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
s1 = r3
End Sub

Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
s2 = r5
End Sub

Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
s2 = r6
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sum = s1 + s2
End Sub

please point the difference between this and your code accept variable name........
don't try copy paste......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.