Jump to content
Xtreme .Net Talk

thankins

Members
  • Posts

    24
  • Joined

  • Last visited

Everything posted by thankins

  1. anyone??! PLEASE!
  2. When I add the count like you told me me too I recieve this error during run time If Lotto(count) = UserNum(count) Again here is my code Dim Lotto(4) As Integer Dim UserNum(4) As Integer Dim count As Integer Dim NumMatch As Integer Sub GetNum() For count = 0 To 4 UserNum(count) = Val(InputBox("Please enter a number for lotto number ", "lotto Number" & _ (count + 1).ToString)) CheckNum() '<== Do the nubmer check here. Next count End Sub Sub Random5Numbers() Randomize() 'Initializes the random-number generator. For count = 0 To 4 'Puts the 5 numbers into the Array Lotto(count) = Int(0 + Rnd() * (9 - 0)) Next count 'Show the five numbers on a textbox, just for testing... 'MessageBox.Show(Lotto(0) & ";" & Lotto(1) & ";" & Lotto(2) & ";" & Lotto(3) & ";" & Lotto(4)) End Sub Sub CheckNum() Dim frmSplash As New frmSplashScreen() 'declare instance of Form If Lotto(count) = UserNum(count) Then ' check to see if number match NumMatch = NumMatch + 1 ' if they do, then add 1 to the count of numbers matched lblDisplay.Text = NumMatch If NumMatch = 5 Then ' check to see if user got all right. frmSplash.Show() ' if they got them all right, then show the Form End If End If End Sub
  3. Well I figured out how to do my program but I recieve this error in this part of my code If Lotto(count) = UserNum Then ' check to see if number match And I dont know what it means. Here is my code Dim Lotto(4) As Integer Dim UserNum(4) As Integer Dim count As Integer Dim NumMatch As Integer Sub GetNum() For count = 0 To 4 UserNum(count) = Val(InputBox("Please enter a number for lotto number ", "lotto Number" & _ (count + 1).ToString)) Next count End Sub Sub Random5Numbers() Randomize() 'Initializes the random-number generator. For count = 0 To 4 'Puts the 5 numbers into the Array Lotto(count) = Int(0 + Rnd() * (9 - 0)) Next count 'Show the five numbers on a textbox, just for testing... 'MessageBox.Show(Lotto(0) & ";" & Lotto(1) & ";" & Lotto(2) & ";" & Lotto(3) & ";" & Lotto(4)) End Sub Sub CheckNum() If Lotto(count) = UserNum Then ' check to see if number match NumMatch = NumMatch + 1 ' if they do, then add 1 to the count of numbers matched End If lblDisplay.Text = NumMatch End Sub Any help wouldbe great!
  4. ok, the book that I have doesnt really go into array list anywhere in the book, so I would perfer to stay away from them. Looking at your code, and knowing what I know I came to this Public Sub Random5Numbers() Randomize() 'Initializes the random-number generator. For count = 0 To 4 'Puts the 5 numbers into the Array Lotto(count) = Int(0 + Rnd() * (9 - 0)) Next count Would that work? I really didnt need the messagebox because I dont want to user to know what numbers have been seleceted. and as far as having the user enter his 5 chocies what should i do ?
  5. here is what I have so far. Dim Lotto(4) As Integer Dim UserNum(4) As String Dim count As Integer Sub GetNum() For count = 0 To 4 UserNum(count) = Val(InputBox("Please enter a number." & _ (count + 1).ToString)) Next count End Sub Sub RndNum() Dim randomNum As Integer Dim count As Integer Randomize() For count = 0 To 4 Lotto(count) = randomNum = 1 + Int(Rnd() * 9) Next count End Sub
  6. Hello everyone, I am trying to teach myself VB and so far have been very successful, but I have ran into a problem. Here it is. I am trying to create a lottery application that has an array of 5 numbers and that will generate a set of five numbers in the range of 0 to 9 for each array. Then the user should enter 5 numbers from Input boxes and they should be stored in another arrary. A for should display how many of the numbers match. The reason I cant figure it out is becasue the book I am using is missing a few pages and so I dont know really where to begin. I know that I have to have two arrays, but i dont really know where to go from there. Any help would be greatly appreciated!!!!!! Thank you Travis
  7. so you mean something like this frmMain.lblTotalDisplay.Text = frmWheel.wheelPrice , where WheelPrice is a variable storing the value from the selected radio button on the second form?
  8. Here is my probelm, I have one project and multiple forms. The main form called frmMain has blank labels on them to display totals, my second form called frmWheels, has radio buttons that contain text that shows the price. And when the user selects a radio button and then click a ADD button the the form to copy the price to the first form blank label. My problem is that I dont know how to get the prices from the second form to the first form
  9. Yes I do, but I want to have a way so that if the user doesnt enters the percent sign the program won't crash, so i should use the if statement then correct?! Also while we are on the topic of percent, how would you go about turning the number they enter into a percent? Because now how I have the program set up it just treats it as a whole number Function Fed_Tax(ByRef grossPay As Single, ByRef fedTax As Single) As Single 'Compute amount to be taken for Federal Tax Fed_Tax = grossPay * fedTax I thought about adding a ".01 to the fed tax so that it reads Function Fed_Tax(ByRef grossPay As Single, ByRef fedTax As Single) As Single 'Compute amount to be taken for Federal Tax Fed_Tax = grossPay * (fedTax * .01) But i didnt know if that was "good programming" or not.
  10. It just says "." or if i enter .05 it says ".0" Is this because i am entering a smaller amount then 1?
  11. Thank you Derek, I have added that site to my favorites and will be checking it out!
  12. I put it into my code and now i recieve a new error I copied it from what was posted fedTax = Single.Parse(txtFederal.Text.Substring(0, txtFederal.Text.Length - 1))
  13. What exact is the single.parse command? I looked in my vb . net book and didnt see anything. Do you mind explaining it
  14. I also forgot to mention that option strict is set to on!
  15. I recieve the following message when i try to compile my program, and I dont know what it means! I am trying to make it so when the user enters a number with the percent sign (10%) into my text box the program will treat it like 10.0 Here are parts of my code Private Sub txtFederal_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtFederal.Validating 'Vaildates that a number has been entered into the text box If Not IsNumeric(Val(txtFederal.Text)) Then MessageBox.Show("Federal taxes must be a number.", "Invaild Input", MessageBoxButtons.OK, _ MessageBoxIcon.Error) 'Select the existing text in the text box. txtFederal.SelectionStart = 0 txtFederal.SelectionLength = txtFederal.Text.Length 'Set the e.Cacel to true so the focus will stay in the control e.Cancel = True Else e.Cancel = False End If End Sub and here is the part where the error is occuring Sub InputData(ByRef empName As String, ByRef hrRate As Single, ByRef hrsWorked As Single, ByRef fedTax As Single, ByRef ficaTax As Single, ByRef stateTax As Single) ' Get payroll data for employee empName = txtName.Text hrRate = CInt(txtRate.Text) hrsWorked = CInt(txtHours.Text) [color=blue]fedTax = CSng(txtFederal.Text)[/color] ficaTax = CSng(txtFica.Text) stateTax = CSng(txtState.Text) The bluw text above is where the error is occuring
  16. yea Sorry i didnt explain it better This is a payroll program that will caluclate Gross Pay, and taxes (Fica Federal and state) the user will enter a name and enter the total hours worked, payrate, and the percent of taxes for each tax. and then it will display the gross pay and etc in a listbox. I need to limit it so that the user can only enter 4 employess into the textboxes. I thought and if statement like this would work Dim count as short Do count while < 4 count+=1 if count = 4 'disable all the boxes and fire message; messagebox.show("You have reached the maximum for employees allowed to be entered", "Maximum Reached") I just didnt know where to put it
  17. I need help. Here is my problem I need an if statement that would stop the user from entering more data into the textboxes after they enter the data 4 times. I dont know how to do it as of now. Here is my code. Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click End End Sub Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click txtState.Text = " " txtFederal.Text = " " txtFica.Text = " " txtHours.Text = " " txtRate.Text = " " txtName.Text = " " lstOutput.Items.Clear() txtName.Focus() End Sub Private Sub txtHours_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtHours.Validating 'Vaildates that a number has been entered into the text box If Not IsNumeric(txtHours.Text) Then MessageBox.Show("Hours worked must be a number.", "Invaild Input", MessageBoxButtons.OK, _ MessageBoxIcon.Error) 'Select the existing text in the text box. txtHours.SelectionStart = 0 txtHours.SelectionLength = txtHours.Text.Length 'Set the e.Cacel to true so the focus will stay in the control e.Cancel = True Else e.Cancel = False End If End Sub Private Sub txtRate_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtRate.Validating 'Vaildates that a number has been entered into the text box If Not IsNumeric(txtRate.Text) Then MessageBox.Show("Pay Rate must be a number.", "Invaild Input", MessageBoxButtons.OK, _ MessageBoxIcon.Error) 'Select the existing text in the text box. txtRate.SelectionStart = 0 txtRate.SelectionLength = txtRate.Text.Length 'Set the e.Cacel to true so the focus will stay in the control e.Cancel = True Else e.Cancel = False End If End Sub Private Sub txtState_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtState.Validating 'Vaildates that a number has been entered into the text box If Not IsNumeric(txtState.Text) Then MessageBox.Show("State taxes must be a number.", "Invaild Input", MessageBoxButtons.OK, _ MessageBoxIcon.Error) 'Select the existing text in the text box. txtState.SelectionStart = 0 txtState.SelectionLength = txtState.Text.Length 'Set the e.Cacel to true so the focus will stay in the control e.Cancel = True Else e.Cancel = False End If End Sub Private Sub txtFederal_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtFederal.Validating 'Vaildates that a number has been entered into the text box If Not IsNumeric(txtFederal.Text) Then MessageBox.Show("Federal taxes must be a number.", "Invaild Input", MessageBoxButtons.OK, _ MessageBoxIcon.Error) 'Select the existing text in the text box. txtFederal.SelectionStart = 0 txtFederal.SelectionLength = txtFederal.Text.Length 'Set the e.Cacel to true so the focus will stay in the control e.Cancel = True Else e.Cancel = False End If End Sub Private Sub txtFica_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtFica.Validating 'Vaildates that a number has been entered into the text box If Not IsNumeric(txtFica.Text) Then MessageBox.Show("F.I.C.A. withholdings must be a number.", "Invaild Input", MessageBoxButtons.OK, _ MessageBoxIcon.Error) 'Select the existing text in the text box. txtFica.SelectionStart = 0 txtFica.SelectionLength = txtFica.Text.Length 'Set the e.Cacel to true so the focus will stay in the control e.Cancel = True Else e.Cancel = False End If End Sub 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, ficaTax, stateTax) grossPay = Gross_Pay(hrRate, hrsWorked) fedTax = Fed_Tax(grossPay, fedTax) ficaTax = Fica_Tax(grossPay, ficaTax) 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, ByRef ficaTax As Single, ByRef stateTax As Single) ' Get payroll data for employee empName = txtName.Text hrRate = CInt(txtRate.Text) hrsWorked = CInt(txtHours.Text) fedTax = CSng(txtFederal.Text) ficaTax = CSng(txtFica.Text) stateTax = CSng(txtState.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 lstOutput.Items.Add("Payroll results for " + (empName)) lstOutput.Items.Add(" Gross pay this period:" + FormatCurrency(pay)) lstOutput.Items.Add(" F.I.C.A. tax withheld:" + 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 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 Fed_Tax = 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 Fica_Tax = 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 State_Tax = grossPay * stateTax End Function Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class Thank you for your help!
  18. Does anyone know how to accept percent and decimals in a text box? Also does anyone know how to limit the times a user can input data? 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! My problem is that I dont know how to allow the user to enter a percent in a textbox or decimal, if they enter either of those the program won't calculate it. But if i enter a whole number it works fine! Also I dont know how to limit the user from entering more then 4 names. I thought about using a Do While loop by but didnt know where to place it. Here is my code Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click End End Sub Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click txtState.Text = " " txtFederal.Text = " " txtFica.Text = " " txtHours.Text = " " txtRate.Text = " " txtName.Text = " " lstOutput.Items.Clear() txtName.Focus() End Sub Private Sub txtHours_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtHours.Validating 'Vaildates that a number has been entered into the text box If Not IsNumeric(txtHours.Text) Then MessageBox.Show("Hours worked must be a number.", "Invaild Input", MessageBoxButtons.OK, _ MessageBoxIcon.Error) 'Select the existing text in the text box. txtHours.SelectionStart = 0 txtHours.SelectionLength = txtHours.Text.Length 'Set the e.Cacel to true so the focus will stay in the control e.Cancel = True Else e.Cancel = False End If End Sub Private Sub txtRate_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtRate.Validating 'Vaildates that a number has been entered into the text box If Not IsNumeric(txtRate.Text) Then MessageBox.Show("Pay Rate must be a number.", "Invaild Input", MessageBoxButtons.OK, _ MessageBoxIcon.Error) 'Select the existing text in the text box. txtRate.SelectionStart = 0 txtRate.SelectionLength = txtRate.Text.Length 'Set the e.Cacel to true so the focus will stay in the control e.Cancel = True Else e.Cancel = False End If End Sub Private Sub txtState_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtState.Validating 'Vaildates that a number has been entered into the text box If Not IsNumeric(txtState.Text) Then MessageBox.Show("State taxes must be a number.", "Invaild Input", MessageBoxButtons.OK, _ MessageBoxIcon.Error) 'Select the existing text in the text box. txtState.SelectionStart = 0 txtState.SelectionLength = txtState.Text.Length 'Set the e.Cacel to true so the focus will stay in the control e.Cancel = True Else e.Cancel = False End If End Sub Private Sub txtFederal_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtFederal.Validating 'Vaildates that a number has been entered into the text box If Not IsNumeric(txtFederal.Text) Then MessageBox.Show("Federal taxes must be a number.", "Invaild Input", MessageBoxButtons.OK, _ MessageBoxIcon.Error) 'Select the existing text in the text box. txtFederal.SelectionStart = 0 txtFederal.SelectionLength = txtFederal.Text.Length 'Set the e.Cacel to true so the focus will stay in the control e.Cancel = True Else e.Cancel = False End If End Sub Private Sub txtFica_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtFica.Validating 'Vaildates that a number has been entered into the text box If Not IsNumeric(txtFica.Text) Then MessageBox.Show("F.I.C.A. withholdings must be a number.", "Invaild Input", MessageBoxButtons.OK, _ MessageBoxIcon.Error) 'Select the existing text in the text box. txtFica.SelectionStart = 0 txtFica.SelectionLength = txtFica.Text.Length 'Set the e.Cacel to true so the focus will stay in the control e.Cancel = True Else e.Cancel = False End If End Sub 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, ficaTax, stateTax) grossPay = Gross_Pay(hrRate, hrsWorked) fedTax = Fed_Tax(grossPay, fedTax) ficaTax = Fica_Tax(grossPay, ficaTax) 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, ByRef ficaTax As Single, ByRef stateTax As Single) ' Get payroll data for employee empName = txtName.Text hrRate = CInt(txtRate.Text) hrsWorked = CInt(txtHours.Text) fedTax = CSng(txtFederal.Text) ficaTax = CSng(txtFica.Text) stateTax = CSng(txtState.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 lstOutput.Items.Add("Payroll results for " + (empName)) lstOutput.Items.Add(" Gross pay this period:" + FormatCurrency(pay)) lstOutput.Items.Add(" F.I.C.A. tax withheld:" + 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 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 Fed_Tax = 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 Fica_Tax = 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 State_Tax = grossPay * stateTax End Function Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class
  19. hnn I dont really know what you mean by UI, I am just storing the employees name in the list box and then want it to clear the form and allow the user to add another name. I was thinking about using a do while loop but really didnt know how to put it in, everytime i did it would allow me to enter one name and then it would just add that one name 4 times!!!
  20. sorry I really didnt describe my first error that well, I get them here (the underline parts) lstOutput.Items.Add("Payroll results for ", & empName) and the following outputs!
  21. 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. 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! :D Travis :D :D
  22. hmm What do you mean, I am not knowing what the NumericUpDown function is.
  23. Oh yea Option Strict is set to ON as part of the program prerequiste so I can't have any implicit conversions! :confused:
  24. I am working on a program and it calls for input validation for the text that the user enters into the text box. It does not want negative numbers or strings (i.e. "abcd..."). I understand how to do the negative numbers part of the validation but not the string part of the validation. Here is what I have so far. I thought the IsNumeric funtion would work on it but I have a run-time error in and when I enter a letter (such as ABC) it doesnt do anything. Dim distance As Long 'Gets the distance for medium If IsNumeric(txtDistance.Text) Then distance = Val(txtDistance.Text) 'Validate text to make sure no negatives number or strings where 'entered into the text box If distance < 0 Then MessageBox.Show("Please enter positive number for " & _ "the distance for your selected medium.", "Text Error", MessageBoxButtons.OK, _ MessageBoxIcon.Error) End If End If Also Does anyone know how to round numbers to just two decimal places. I am using the data entered in the textbox with some variables and then displaying the answer in a label, but when the math is complete I get 9.099990999 as an output and I just want it to be 9.09 Thanks ahead of time for the help!
×
×
  • Create New...