Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Can't make radio buttons work...If then else statement

ok...I can't get the radPackageB button to work properly. The radPackageA works just fine but that's where I start having trouble. Please help me. The code that is bold is where I get stuck. Thank you

'Calculate Service Fees based on user input of hours and selected package
Dim hours As Single
Dim servicefees As Decimal
Const PackageA As Single = 9.95
Const PackageB As Single = 14.95
Const PackageC As Single = 19.95
hours = Val(txtHours.Text)

If txtHours.Text.Trim.Length = 0 Then
MessageBox.Show("Please enter number of hours used.", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtHours.Focus()
Else
If IsNumeric(txtHours.Text) = False Then
MessageBox.Show("Please enter numbers only.", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtHours.Focus()
Else
If Val(txtHours.Text) <= 0 Then
MessageBox.Show("Hours must be greater than 0.", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
If Val(txtHours.Text) >= 745 Then
MessageBox.Show("Hours cannot be greater than 744.", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtHours.Focus()
Else
If radPackageA.Checked = True Then
If Val(txtHours.Text) <= 10 Then
lblServiceFees.Text = FormatCurrency(PackageA)
Else
If Val(txtHours.Text) >= 10 Then
lblServiceFees.Text = FormatCurrency(PackageA + ((txtHours.Text - 10) * 2))

Else
[b]If radPackageB.Checked = True Then
If Val(txtHours.Text) <= 20 Then
lblServiceFees.Text = FormatCurrency(PackageB)
Else
If Val(txtHours.Text) >= 21 Then
lblServiceFees.Text = FormatCurrency(PackageB + ((txtHours.Text - 20) * 1))[/b] End If
End If
End If
End If
End If
End If
End If
End If
End If

End If

Comments

  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    : ok...I can't get the radPackageB button to work properly. The
    : radPackageA works just fine but that's where I start having trouble.
    : Please help me. The code that is bold is where I get stuck. Thank
    : you
    :

    The check for radPackageB is inside the chech for radPackageA, so it will never work.
    Move it to the same level as radPackageA
    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
Sign In or Register to comment.