我首先在VB中使用单选按钮,但我无法弄清楚我做错了什么。 click事件假设是将两个输入相乘,但无论输入什么数字,结果都会返回0。
我正在使用的代码是:
回
Dim decTotal As Decimal 'Total charge for choice plan
Dim intMinutes As Integer 'Duration of phone calls
'Declare constants for Rates
Const decDaytimeRate As Decimal = 0.07D
Const decEveningRate As Decimal = 0.12D
Const decOffPeakRate As Decimal = 0.05D
'Dispay Total charge
lblTotal.Text = decTotal.ToString("c")
'Calculate total amount the user is expected to pay according to rate plan
If radDaytime.Checked = True Then
decTotal = intMinutes * decDaytimeRate
End If
If radEvening.Checked = True Then
decTotal = decEveningRate * intMinutes
End If
我确信这是一个简单的修复,因为我没有丢失任何错误消息,但我仍然被卡住了。
答案 0 :(得分:0)
将lblTotal.Text = decTotal.ToString(“c”)行移至末尾。它在你计算之前显示结果。