Can anyone take a look at this? I'm getting a "Conversion from string "" to type 'Double' is not valid." for this line - income = CDbl(txtIncome.Text).
Any other help would be great if you can find any errors.
Thanks!
Public Class Form1
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
Dim income, tax As Double
income = CDbl(txtIncome.Text)
tax = GetTaxableIncome(income)
Displayfederaltax(tax)
End Sub
Function GetTaxableIncome(ByVal income)
Dim tax As Double
If income > 0 And income <= 8700 Then
tax = income * 0.1
ElseIf income <= 35350 Then
tax = 870 + (income - 8700) * 0.15
ElseIf income <= 85650 Then
tax = 4867.5 + (income - 35350) * 0.25
ElseIf income <= 178650 Then
tax = 17442.5 + (income - 85650) * 0.28
ElseIf income <= 388350 Then
tax = 43482.5 + (income - 178650) * 0.33
Else
tax = 112683.5 + (income - 388350) * 0.35
End If
Return tax
End Function
Private Function Displayfederaltax(ByVal tax)
Dim taxstring As String
taxstring = FormatCurrency(tax, 2, True, True, True)
txtDisplay.Text = taxstring
Return True
End Function
Private Sub txtInput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtInput.TextChanged
End Sub
End Class
Any other help would be great if you can find any errors.
Thanks!
Public Class Form1
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
Dim income, tax As Double
income = CDbl(txtIncome.Text)
tax = GetTaxableIncome(income)
Displayfederaltax(tax)
End Sub
Function GetTaxableIncome(ByVal income)
Dim tax As Double
If income > 0 And income <= 8700 Then
tax = income * 0.1
ElseIf income <= 35350 Then
tax = 870 + (income - 8700) * 0.15
ElseIf income <= 85650 Then
tax = 4867.5 + (income - 35350) * 0.25
ElseIf income <= 178650 Then
tax = 17442.5 + (income - 85650) * 0.28
ElseIf income <= 388350 Then
tax = 43482.5 + (income - 178650) * 0.33
Else
tax = 112683.5 + (income - 388350) * 0.35
End If
Return tax
End Function
Private Function Displayfederaltax(ByVal tax)
Dim taxstring As String
taxstring = FormatCurrency(tax, 2, True, True, True)
txtDisplay.Text = taxstring
Return True
End Function
Private Sub txtInput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtInput.TextChanged
End Sub
End Class