Question: I just created this visual basic application and it seems to run properly but I want an error message to appear when (State Tax+ Federal

I just created this visual basic application and it seems to run properly but I want an error message to appear when (State Tax+ Federal Tax+ FICA Tax) > Gross pay AND should Not do the calculation if (State Tax+ Federal Tax+ FICA Tax) > Gross pay. the error message appears but the program do the calculation when (State Tax+ Federal Tax+ FICA Tax) > Gross pay and I don't want to do it in this point, so what I can do? this is what the question asked me to do- Create an application that displays payroll information. The application should allow the user to enter the following data for four employees -Number of hours worked -Hourly Pay -Percentage to be withheld for state income tax -Percentage to be withheld federal income tax -Percentage to be withheld for FICA application should calculate and display the following data for each employee in a list box. -Gross pay (number of hours worked multiplied by the hourly pay rate) -State income tax withholdings (gross pay multiplied by state income tax percentage) -Federal income tax withholdings (gross pay multiplied by federal income tax percentage) -FICA withholdings (gross pay multiplied by FICA percentage) Net pay (the gross pay minus state income tax , federal income tax and FICA) When the calculations are performed be sure to check for the following error- If an employees state income tax plus federal tax plus FICA is greater than the employees gross pay, display an error message stating that the withholdings are too great. Be sure to add appropriate ToolTips for each control on the form.

This is my code for This point

Dim intcount As Integer = 0 ' To hold counter variable.

Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click Dim Grosspay As Double ' To hold Grosspay. Dim StateIncome As Double ' To hold State income tax. Dim FederalIncome As Double ' To hold Federal income tax. Dim Fica, FciaIn As Double ' To hold FICA. Dim NetPay As Integer ' To hold Netpay. Dim State As Double ' To hold state income tax. Dim Federal As Double ' To hold federal income tax. Dim Hour As Integer ' To hold hours. Dim HourRate As Integer ' To hold employee rate. ' To generate US currency format. Dim currency As Globalization.CultureInfo = Globalization.CultureInfo.CreateSpecificCulture("en-US")

' Get input from text box hours worked and convert in to integer. Hour = CInt(txtHoursWorked.Text) ' Get input from text box HourRate and convert in to integer. HourRate = CInt(txtHourlyPayRate.Text) ' Convert StateIncomeTax textbox to double-precision floating-point number. State = Double.Parse(txtStateIncomeTax.Text) ' Convert FedralIncomeTax textbox to double-precision floating-point number. Federal = Double.Parse(txtFedralIncomeTax.Text) ' Convert FICA textbox to double-precision floating-point number. FciaIn = Double.Parse(txtFICA.Text) ' Calculate grosspay, stateIncome, federalIncome 'fica and netPay. ' Multiply hour with hourrste to get Grosspay. Grosspay = (Hour * HourRate) ' Multiply grosspay with state tax and divide by 100 to get State Income. StateIncome = (Grosspay * State) / 100.0 ' Multiply grosspay with federal tax and divide by 100 to get federal Income. FederalIncome = ((Grosspay * Federal) / 100.0) ' Multiply grosspay with FICA withholding and divide by 100 to get State Income. Fica = ((Grosspay * FciaIn) / 100.0) ' Substract gross pay from the total of State income, federal income and Fica 'and convert it to integer. NetPay = CInt((Grosspay - (StateIncome + FederalIncome + Fica))) ' Condition to check whether the sum of state income tax 'federal income tax, and FICA are greater than gross pay ' if so, display an error message.

If (State + Federal + FciaIn) > Grosspay Then

MessageBox.Show("With holdings are too high") End If ' Display output in the list box with two decimals. lstOutput.Items.Add(Grosspay.ToString("c2", currency) & Space(20) & StateIncome.ToString("c2", currency) & Space(25) & FederalIncome.ToString("c2", currency) & Space(25) & Fica.ToString("c2", currency) & Space(20) & NetPay.ToString("c2", currency)) ' Increment the counter. intcount += 1 ' If four employee details are filled, stop the 'program by disabling the text boxes. If (intcount >= 4) Then MessageBox.Show("Sorry, Only four employee" & " details are allowed.") txtHoursWorked.Enabled = False txtHourlyPayRate.Enabled = False txtStateIncomeTax.Enabled = False txtFedralIncomeTax.Enabled = False txtFICA.Enabled = False txtHoursWorked.Clear() txtHourlyPayRate.Clear() txtStateIncomeTax.Clear() txtFedralIncomeTax.Clear() txtFICA.Clear() End If

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!