我的輸出始終是14.95包A ..所有其他東西似乎工作正常。Visual Basic - 開始程序代碼
對於程序,我需要:
的互聯網服務provicer提供3個訂閱套餐的客戶,加上非營利組織
折扣- packaga答:10小時,每月$ 9.95訪問。額外的是每小時2.00美元。
- 套餐B:20美元的訪問時間爲每月14.95美元。附加每
- 包C $ 1.00:1爲$ 19.95無限接入每月
- 非營利組織:如果用戶選擇了非營利組織複選框應該從最後的費用中扣除20 %的折扣。 輸入驗證「:如果在一個月內使用不能超過744小時數..的值必須是數字
btnCalc_Click
Public Class Form1
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
'Declare variables and constant
Dim decTotal As Decimal
Dim intHours As Integer
Const decNonProfit As Decimal = 0.8D
Try
intHours = CInt(txtHoursUsed.Text)
If CInt(txtHoursUsed.Text) > 744 Then
MessageBox.Show("Monthly Hours Can't Exceed 744")
txtHoursUsed.Text = String.Empty
lblTotalDue.Text = String.Empty
End If
'Calculate A Package Total without discount
If radPackageA.Checked = True And intHours > 10 Then
decTotal = (9.95 + ((intHours - 10) * 2))
ElseIf intHours <= 10 Then
decTotal = 9.95
End If
'Calculate B Package Total without discount
If radPackageB.Checked = True And intHours > 20 Then
decTotal = (14.95 + ((intHours - 20) * 1))
ElseIf intHours <= 20 Then
decTotal = 14.95
End If
'Calculate C Package Total without discount
If radPackageC.Checked = True Then
decTotal = 19.95
End If
'Calculate Total for packages if Nonprofit is checked
If chkNonProfit.Checked = True Then
decTotal = decTotal * decNonProfit
End If
'Show total due
lblTotalDue.Text = decTotal.ToString("c")
Catch ex As Exception
MessageBox.Show("Input Error")
End Try
End Sub
btnClear_Click
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
radPackageA.Checked = False
radPackageB.Checked = False
radPackageC.Checked = False
chkNonProfit.Checked = False
lblTotalDue.Text = String.Empty
txtHoursUsed.Text = String.Empty
End Sub
btnExit_Click
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
,問題是......? – equisde
我找不到你的代碼有什麼問題。難道是你命名包A'radPackageB'和包B'radPackageA'? – srka
包A輸出無法正常工作..ex。如果包A被檢查,並且我輸入5小時輸出是14.95而不是9.95 ..如果我在文本框中放置20,它會給出14.95 ..它給出14.95。所有其他包輸入/輸出正在工作。 – user3318131