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

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!

Edited 8 Months Ago by Joseph_20

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

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.

Edited 8 Months Ago by Reverend Jim

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.

This article has been dead for over six months. Start a new discussion instead.