I need to FICA and Federal Tax % to a weekly paycheck calculator. I think I have everything in the program that needs to but, I think I might have a line in the wrong spot or in the wrong order. Any help would be greatly appreciated. Thank you.

Public Class Form1

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()

    End Sub

  
    Private Sub btnCal_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCal.Click
        Dim payRate As Decimal
        Dim grossPay As Decimal
        Dim netPay As Decimal
        Dim hoursWorked As Integer
        Dim annual As Decimal
        Dim fedTax As Decimal
        Dim fica As Decimal
        Dim totalDeds As Decimal

        payRate = textboxBasePay.Text
        hoursWorked = textboxHours.Text
        
        grossPay = hoursWorked * payRate
        lblGrossPay.Text = FormatCurrency(grossPay)
        annual = grossPay * 52
        totalDeds = fica + fedTax
        lblTotalDeductions.Text = FormatPercent(totalDeds)
        If annual <= 50000 Then
            fedTax = 0.25 And fica = 0.07

        ElseIf annual > 50000 < 120000 Then
            fedTax = 0.31 And fica = 0.15

        Else
            fedTax = 0.35 And fica = 0.15

        End If

        'totalDeds = fica + fedTax
        'lblTotalDeductions.Text = FormatPercent(totalDeds)
        netPay = grossPay - grossPay * totalDeds

        lblNetPay.Text = FormatCurrency(netPay)
        '        lblTotalDeductions.Text = FormatPercent(totalDeds)
        Label8.Text = FormatPercent(fedTax)
        Label10.Text = FormatPercent(fica)


    End Sub

End Class

any ideas on this one, I'm still stumped.

There's a couple things I see.

first off, if you're assigning number values (int, dec) from string controls (textbox) into number variables, you must CInt or CDec the textbox. This will convert.

payRate = CDec(textboxBasePay.Text)
hoursWorked = CInt(textboxHours.Text)

Also, are fica and fedTax NULL when you are determining total deductions?
Your variables don't contain values as constants and you aren't assigning values from a textbox to them before this line:

totalDeds = fica + fedTax

So my guess would be to move that under your If statement that is assigning a value to those variables.

Hope this helps,

Lee

I moved

totalDeds = fica + fedTax

under the if statement and I'm still getting NULL values for fedtax, fica and total deducation

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.