Need Help with creating a simple payroll form

Elrey

New member
Joined
Mar 7, 2005
Messages
2
Programming Experience
10+
im new to vb and really have no clue so im looking for some help, i need to create a simple payroll system as a form in ms access. In this application i need to add the functionality to compute the pay for each worker at two different pay rates. In this case i will have a rate of £10 per hour for workers who are in the Sales Department and a rate of £7.50 per hour for workers in the Processing Department.



A standard working week for both categories of employee is 40 hours. Any time in addition to the standard week is paid at an overtime rate equivalent to one and a half times the normal pay rate for each category of employee.



Each employee can earn up to £4, 500 per year tax free, after that they pay 22% tax. Tax is deducted on any pay that is over the weekly equivalent of the annual tax allowance (assume a 52 week year).

does anyone know what the coding for this would be?
 
Take a look at this. It is a book I bought to learn Visual Studio .net. The language is visual basic .net. It should cover most of what you need except for the tax part. When I have a free moment I will try to figure it out.
Public
Class FrmWageCalculator
Inherits System.Windows.Forms.Form

#
Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents lblWage As System.Windows.Forms.Label

Friend WithEvents lblHours As System.Windows.Forms.Label

Friend WithEvents txtWage As System.Windows.Forms.TextBox

Friend WithEvents txtHours As System.Windows.Forms.TextBox

Friend WithEvents lblEarningsResult As System.Windows.Forms.Label

Friend WithEvents lblEarnings As System.Windows.Forms.Label

Friend WithEvents btnCalculate As System.Windows.Forms.Button

<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()

Me.lblWage = New System.Windows.Forms.Label

Me.lblHours = New System.Windows.Forms.Label

Me.txtWage = New System.Windows.Forms.TextBox

Me.txtHours = New System.Windows.Forms.TextBox

Me.lblEarningsResult = New System.Windows.Forms.Label

Me.btnCalculate = New System.Windows.Forms.Button

Me.lblEarnings = New System.Windows.Forms.Label

Me.SuspendLayout()

'

'lblWage

'

Me.lblWage.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

Me.lblWage.Location = New System.Drawing.Point(16, 16)

Me.lblWage.Name = "lblWage"

Me.lblWage.Size = New System.Drawing.Size(80, 21)

Me.lblWage.TabIndex = 8

Me.lblWage.Text = "Hourly wage:"

Me.lblWage.TextAlign = System.Drawing.ContentAlignment.MiddleLeft

'

'lblHours

'

Me.lblHours.Location = New System.Drawing.Point(16, 56)

Me.lblHours.Name = "lblHours"

Me.lblHours.Size = New System.Drawing.Size(80, 21)

Me.lblHours.TabIndex = 10

Me.lblHours.Text = "Weekly hours:"

Me.lblHours.TextAlign = System.Drawing.ContentAlignment.MiddleLeft

'

'txtWage

'

Me.txtWage.Location = New System.Drawing.Point(112, 16)

Me.txtWage.Name = "txtWage"

Me.txtWage.Size = New System.Drawing.Size(64, 21)

Me.txtWage.TabIndex = 11

Me.txtWage.Text = "0"

Me.txtWage.TextAlign = System.Windows.Forms.HorizontalAlignment.Right

'

'txtHours

'

Me.txtHours.Location = New System.Drawing.Point(112, 56)

Me.txtHours.Name = "txtHours"

Me.txtHours.Size = New System.Drawing.Size(64, 21)

Me.txtHours.TabIndex = 12

Me.txtHours.Text = "0"

Me.txtHours.TextAlign = System.Windows.Forms.HorizontalAlignment.Right

'

'lblEarningsResult

'

Me.lblEarningsResult.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D

Me.lblEarningsResult.Location = New System.Drawing.Point(112, 96)

Me.lblEarningsResult.Name = "lblEarningsResult"

Me.lblEarningsResult.Size = New System.Drawing.Size(64, 21)

Me.lblEarningsResult.TabIndex = 13

Me.lblEarningsResult.TextAlign = System.Drawing.ContentAlignment.MiddleCenter

'

'btnCalculate

'

Me.btnCalculate.Location = New System.Drawing.Point(112, 136)

Me.btnCalculate.Name = "btnCalculate"

Me.btnCalculate.Size = New System.Drawing.Size(64, 24)

Me.btnCalculate.TabIndex = 14

Me.btnCalculate.Text = "Calculate"

'

'lblEarnings

'

Me.lblEarnings.Location = New System.Drawing.Point(16, 96)

Me.lblEarnings.Name = "lblEarnings"

Me.lblEarnings.Size = New System.Drawing.Size(88, 21)

Me.lblEarnings.TabIndex = 15

Me.lblEarnings.Text = "Gross earnings:"

Me.lblEarnings.TextAlign = System.Drawing.ContentAlignment.MiddleLeft

'

'FrmWageCalculator

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)

Me.ClientSize = New System.Drawing.Size(192, 173)

Me.Controls.Add(Me.lblEarnings)

Me.Controls.Add(Me.btnCalculate)

Me.Controls.Add(Me.lblEarningsResult)

Me.Controls.Add(Me.txtHours)

Me.Controls.Add(Me.txtWage)

Me.Controls.Add(Me.lblHours)

Me.Controls.Add(Me.lblWage)

Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

Me.Name = "FrmWageCalculator"

Me.Text = "Wage Calculator"

Me.ResumeLayout(False)

End Sub

#End Region

'handles btnCalculate click event

Private Sub btnCalculate_Click(ByVal sender As _

System.Object,
ByVal e As System.EventArgs) _

Handles btnCalculate.Click

'declare variables

Dim dblHours As Double

Dim decWage As Decimal

Dim decEarnings As Decimal

'declare constant

Const intHOUR_LIMIT As Integer = 40

'assign values from user input

dblHours = Val(txtHours.Text)

decWage = Val(txtWage.Text)

'determine wage amount

If dblHours <= intHOUR_LIMIT Then

'if under or equal to 40 hours, regular wages

decEarnings = dblHours * decWage

Else

'if over 40 hours, regular wages for first 40 hours

decEarnings = intHOUR_LIMIT * decWage

'time and a half for the additional over 40 hours

decEarnings = decEarnings + _

(dblHours - intHOUR_LIMIT) * (1.5 * decWage)

End If

'assign the results to its corresponding label

lblEarningsResult.Text = String.Format("{0:C}", decEarnings)

End Sub 'btnCalculate_Click

End Class ' FrmWageCalculator

' **************************************************************************

' * (C) Copyright 2003 by Deitel & Associates, Inc. and Prentice Hall. *

' * All Rights Reserved. *

' * *

' * DISCLAIMER: The authors and publisher of this book have used their *

' * best efforts in preparing the book. These efforts include the *

' * development, research, and testing of the theories and programs *

' * to determine their effectiveness. The authors and publisher make *

' * no warranty of any kind, expressed or implied, with regard to these *

' * programs or to the documentation contained in these books. The authors *

' * and publisher shall not be liable in any event for incidental or *

' * consequential damages in connection with, or arising out of, the *

' * furnishing, performance, or use of these programs. *

' **************************************************************************

 

Latest posts

Back
Top