Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 16044

VS 2019 How to do calculation using radio button and check box?

$
0
0
Here's the pic of my form
Name:  Screenshot 2021-06-13 175136.jpg
Views: 41
Size:  14.4 KB
.For class size, small =$80, medium = $75, large = $70 and $35/per subject. I need to calculate the total. There're some problems with my code, can u guys give some suggestions please.
Code:

  Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
        Dim dblTotal As Double
        Dim checkedCheckBox As Integer = 0 'CheckBox checked
        Dim totalCheckBox As Integer = 0 'Total CheckBox on Group Box

        For Each myControl As CheckBox In Me.grpClassSize.Controls.OfType(Of CheckBox)()
            If myControl.Checked Then
                checkedCheckBox += 1
            End If
            totalCheckBox += 1
        Next

        If radSmall.Checked = True Then
            If totalCheckBox = 1 Then
                dblTotal = 80 * (35 * 1)
            ElseIf totalCheckBox = 2 Then
                dblTotal = 80 * (35 * 2)
            ElseIf totalCheckBox = 3 Then
                dblTotal = 80 * (35 * 3)
            ElseIf totalCheckBox = 4 Then
                dblTotal = 80 * (35 * 4)
            End If
        End If

        If radMedium.Checked = True Then
            If totalCheckBox = 1 Then
                dblTotal = 75 * (35 * 1)
            ElseIf totalCheckBox = 2 Then
                dblTotal = 75 * (35 * 2)
            ElseIf totalCheckBox = 3 Then
                dblTotal = 75 * (35 * 3)
            ElseIf totalCheckBox = 4 Then
                dblTotal = 75 * (35 * 4)
            End If
        End If

        If radLarge.Checked = True Then
            If totalCheckBox = 1 Then
                dblTotal = 70 * (35 * 1)
            ElseIf totalCheckBox = 2 Then
                dblTotal = 70 * (35 * 2)
            ElseIf totalCheckBox = 3 Then
                dblTotal = 70 * (35 * 3)
            ElseIf totalCheckBox = 4 Then
                dblTotal = 70 * (35 * 4)
            End If
        End If

        lblTotal.Text = FormatCurrency(dblTotal, 2)
    End Sub

Attached Images
 

Viewing all articles
Browse latest Browse all 16044

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>