0
我有一個測試即將到來,所以我試圖儘可能在書中儘可能多的問題,但我不明白爲什麼我會得到「c」作爲我的windows窗體應用程序中的輸出。如果任何人都可以幫助,我會很感激。在Visual Basic稅計算器中無法獲得輸出
Private Sub btnCompute_Click(sender As Object, e As EventArgs) Handles
btnCompute.Click
Dim income, tax As Double
income = txtIncome.Text
Select Case income
Case Is > 9225
tax = income * 0.1
Case Is > 37450
tax = 922.5 + 0.15 * (income - 9225)
Case Is > 90750
tax = 5617.5 + 0.25 * (income - 37450)
Case Is > 189300
tax = 22687.5 + 0.28 * (income - 90750)
Case Is > 411500
tax = 53004 + 0.33 * (income - 189300)
Case Is > 413200
tax = 135795 + 0.35 * (income - 411500)
Case Is < 413200
tax = 144620 + 0.396 * (income - 413200)
End Select
txtTax.Text = String.Format("{0: C}", income)
End Sub
如果將項目設置設置爲Option Strict On或者在代碼文件的第一行寫上Option Strict On,您將從編譯器獲得更多幫助,這可以使您找到正確的方法 – Fabio
txtTax.Text = String.Format(「{0:C}」,income)'將停止顯示結果爲「C」。但是你確定你的代碼是正確的嗎? BC我試過了,它沒有做任何計算 – Subaz