I have two RadioButton and Two Checkbox which represents things that holds a value in decimal example price! The user has to choose from either of the radiobutton and also from either of the checkbox. I have a button to culculate the total! I'm using if else statement but got lost somewhere I guess. I need help

where is your code

Public Class Form1
    Dim price1 As Decimal = "$3.95"
    Dim price2 As Decimal = "$7.95"
    Dim price3 As Decimal = "$8.95"
    Dim open As Decimal = "$50.95"
    Dim wine As Decimal = "$40.95"



    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If RadioButton1.Checked = True Then

            TextBox1.Text = price1
            If (CheckBox1.Checked) Then
                TextBox1.Text = price1 + open
            Else
                TextBox1.Text = price1 + wine


            End If
        End If

Thats how far i got for RadioButton1, I Tried to Implement the same code for RadioButton2 but didnt work!

I think the coding is also wrong, Can somebody give an if else statement for that!!

Why is line 12 there? It appears to have no effect.

Also, where is the radiobutton2 code.

You can replace

TextBox1.Text = price1

If (CheckBox1.Checked) Then
    TextBox1.Text = price1 + open
Else
    TextBox1.Text = price1 + wine
End If

with

TextBox1.Text = price1 + IIf(CheckBox1.Checked, open, wine)

I suggest you get into the habit of using descriptive names for your controls or your code will quickly become unreadable.

This is my opinion, you can use another two Radio Buttons in lieu of CheckBoxes. It can give you more simplicity to code the calculations.

In general practice Radio Buttons are used to select only one option and checkboxes to select multiple.

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.