I'm writing a program to calculate internet charges. Three packages, A, B, and C to choose from costing $9.95(10 hours; $2/hour extra), $14.95(15 hours; $1/hour extra) and $19.95(unlimited).
Here is the code I have written for input from masked text boxes (for just one case). I would like to simplify by using check boxes and radio buttons but I have never used them before. Any hints or tips?
Case "A"
If hours < 10 And nonprofit.ToUpper = "Y" Then
lstOutput.Items.Add("Total Cost is " & FormatCurrency(9.95 * 0.8))
'package A with nonprofit status, under limit
ElseIf hours < 10 And nonprofit.ToUpper = "N" Then
lstOutput.Items.Add("Total Cost is " & FormatCurrency(9.95))
'package A without nonprofit status, under limit
ElseIf hours > 10 And nonprofit.ToUpper = "Y" Then
lstOutput.Items.Add("Total Cost is " & FormatCurrency((9.95 + _
(hours - 10) * 2) * 0.8))
'package A with nonprofit status, over limit
ElseIf hours > 10 And nonprofit.ToUpper = "N" Then
开发者_如何学C lstOutput.Items.Add("Total Cost is " & FormatCurrency(9.95 + _
(hours - 10) * 2))
'package A without nonprofit status, over limit
End If
Unless I'm not understanding your question - it should be as simple as modifying your code to include a checkbox, such as for nonprofit, then when you process:
Dim nonprofit As Boolean = NonProfit_CB.Checked
Then checked if nonprofit is true(instead of checking for Y/N):
If nonprofit = True Then
RadioButtons are basically the same as CheckBoxes. Also if you want to group radio buttons together, so only one of the group can be selected, place them in a Group Box...
精彩评论