Good evening everyone! I have a few questions...ok 3 questions to ask.
Here is a little background about the program i am working on:
I need to create an application that calculates and displays payroll for 4 employees. It accepts the following data from the user.
1) Num of hours worked.
2.) Hourly Rate.
3)Precent withheld for Fica.
4)Precent for federal.
5.Percent for State.
It then must NOT allow the user to enter anymore data after the 4 employees have been entered!
So after all that here is my code for the calc_click method, and few Sub and Functions that I created to impress those who looked at the program.
My problem is in the listoutput I recieve numerous errors that says " Too many arguments to 'Public Overloads Function Add(item As Object) As Integer'." I would like it to say which item added is in the output (i.e. Fica = 15.00, Gross Pay:15.00...etc)
My second problem is that for some reason it isnt displaying correctly. I can get some of it to display such as Gross Pay but all the rest are zeros. Any idea!
And finally my third problem is How do I stop the user from entering more then 4 employees like the instructions say?
Thank you for your help!
Travis
Here is a little background about the program i am working on:
I need to create an application that calculates and displays payroll for 4 employees. It accepts the following data from the user.
1) Num of hours worked.
2.) Hourly Rate.
3)Precent withheld for Fica.
4)Precent for federal.
5.Percent for State.
It then must NOT allow the user to enter anymore data after the 4 employees have been entered!
So after all that here is my code for the calc_click method, and few Sub and Functions that I created to impress those who looked at the program.
Code:
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
'Declares local variables for btnCalculate_Click Method
Dim empName As String
Dim hrRate, hrsWorked As Single
Dim stateTax, fedTax As Single
Dim totalPay, grossPay, ficaTax As Single
'Gets data,compute payroll,display results
Call InputData(empName, hrRate, hrsWorked, fedTax)
grossPay = Gross_Pay(hrRate, hrsWorked)
ficaTax = Fica_Tax(grossPay, ficaTax)
fedTax = Fed_Tax(grosspay, fedTax)
stateTax = State_Tax(grosspay, stateTax)
totalPay = CSng(Total_Pay(grossPay, ficaTax, fedTax, stateTax))
Call ShowPayroll(empName, grosspay, totalPay, ficaTax, fedTax, stateTax)
End Sub
Sub InputData(ByRef empName As String, ByRef hrRate As Single, ByRef hrsWorked As Single, ByRef fedTax As Single)
' Enter above two lines as one
' Get payroll data for employee
empName = txtName.Text
hrRate = CInt(Val(txtRate.Text))
hrsWorked = CInt(Val(txtHours.Text))
fedTax = CInt(Val(txtFederal.Text))
End Sub
Sub ShowPayroll(ByRef empName As String, ByRef pay As Single, ByRef totalPay As Single, ByRef ficaTax As Single, ByRef fedTax As Single, ByVal stateTax As Single)
' Payroll output for listbox
' Payroll output for listbox
lstOutput.Items.Add("Payroll results for ", & empName)
lstOutput.Items.Add(" Gross pay this period:", FormatCurrency(pay)
lstOutput.Items.Add(" Fica Taxes this period:", FormatCurrency(ficaTax)
lstOutput.Items.Add(" Federal Income tax withheld:", FormatCurrency(fedTax)
lstOutput.Items.Add(" State Income tax withheld:", FormatCurrency(stateTax)
lstOutput.Items.Add("Net pay:", FormatCurrency(totalpay)
End Sub
Private Function Gross_Pay(ByRef hrWage As Single, ByRef hrsWorked As Single) As Single
' Compute weekly pay before taxes
If hrsWorked <= 40 Then
Gross_Pay = hrsWorked * hrWage
Else
Gross_Pay = CSng(40 * hrWage + (hrsWorked - 40) * 1.5 * hrWage)
End If
End Function
Function Total_Pay(ByRef grossPay As Single, ByRef ficaTax As Single, ByRef fedTax As Single, ByRef stateTax As Single) As String
' Compute amount of net pay
Total_Pay = CStr(grossPay - ficaTax - fedTax - stateTax)
End Function
Function Fed_Tax(ByRef grossPay As Single, ByRef fedTax As Single) As Single
'Compute amount to be taken for Federal Tax
fedTax = grossPay * fedTax
End Function
Function Fica_Tax(ByRef grossPay As Single, ByRef ficaTax As Single) As Single
''Compute amount to be taken for FICA Tax
ficaTax = grossPay * ficaTax
End Function
Function State_Tax(ByRef grossPay As Single, ByRef stateTax As Single) As Single
'Compute amount to be taken for State Tax
stateTax = grossPay * stateTax
End Function
My problem is in the listoutput I recieve numerous errors that says " Too many arguments to 'Public Overloads Function Add(item As Object) As Integer'." I would like it to say which item added is in the output (i.e. Fica = 15.00, Gross Pay:15.00...etc)
My second problem is that for some reason it isnt displaying correctly. I can get some of it to display such as Gross Pay but all the rest are zeros. Any idea!
And finally my third problem is How do I stop the user from entering more then 4 employees like the instructions say?
Thank you for your help!
Travis