【发布时间】:2014-11-18 11:50:31
【问题描述】:
这是一个家庭作业,据我所知,我已经完成了我应该做的所有事情。但是由于某种原因它不起作用。如果我输入“50000”作为物业价值,“.6”作为评估百分比,“.7”作为评估率,我应该得到“210 美元”的物业税,但我一直只得到零,不知道是什么我错过了。直到周日才到期,所以如果你只想给我一个提示,我也会很感激。我已经检查了几次说明和代码,但我仍然没有看到我的错误。我一直在看“propertytaxLabel.Text = CDec(decTax)”,就像我在那里也搞砸了一样。
Public Class Form1
Private Sub clearButton_Click(sender As Object, e As EventArgs) Handles clearButton.Click
valueTextBox.Clear()
percentTextBox.Clear()
rateTextBox.Clear()
propertytaxLabel.Text = ""
End Sub
Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
Dim result As DialogResult
result = MessageBox.Show("Are you sure?", "Exit", MessageBoxButtons.YesNo)
If result = DialogResult.No Then
e.Cancel = True
End If
End Sub
Private Sub calculateButton_Click(sender As Object, e As EventArgs) Handles calculateButton.Click
Try
Dim decValue, decPercent, decRate, decTax As Decimal
decValue = CDec(valueTextBox.Text)
decPercent = CDec(percentTextBox.Text)
decRate = CDec(rateTextBox.Text)
propertytaxLabel.Text = CStr(decTax)
If proceduresRadioButton.Checked = True Then
TaxCalcProc(decValue, decPercent, decRate, decTax)
Else
decTax = TaxCalcFunc(decValue, decPercent, decRate)
End If
FormatCurrency(decTax)
Catch ex As Exception
MessageBox.Show("Error: Did you enter the data correctly?")
End Try
End Sub
Private Sub TaxCalcProc(ByVal propVal As Decimal, ByVal perc As Decimal, ByVal rate As Decimal, ByRef tax As Decimal)
Dim AssessedValue As Decimal
Try
AssessedValue = propVal * perc
tax = AssessedValue / 100 * rate
If rate > 1 Or perc > 1 Then
Throw New Exception("Tax Greater Than Value. Did you use the decimal point?")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Function TaxCalcFunc(ByVal propVal As Decimal, ByVal perc As Decimal, ByVal rate As Decimal) As Decimal
Dim tax As Decimal
Dim AssessedValue As Decimal
Try
AssessedValue = propVal * perc
tax = AssessedValue / 100 * rate
If rate > 1 Or perc > 1 Then
Throw New Exception("Tax Greater Than Value. Did you use the decimal point?")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Return 0
End Try
Return Tax
End Function
结束类
【问题讨论】:
-
开启Option Strict,然后设置断点调试
-
在您的代码隐藏中,右键单击出现错误的行并选择插入断点,然后使用工具栏运行程序
-
没有什么给我一个错误,它只是没有做它应该做的事情。我想我在错误的地方放错了一块,但我找不到它
-
procedureRadioButton 是选中还是未选中?
-
我有“如果程序RadioButton.Checked = True Then”
标签: vb.net