anonymous
2009-05-08 19:22:43 UTC
Sub btnCompute_Click
Sub ClearScreen
Sub CalculateWH
Function GetTheFileName
Sub ReadPayrollData
Sub SavePayrollData
Sub Form1_Load
Sub btnRead_Click
Sub btnSave_Click
Sub Missing
Sub btnSave_Click
Sub Form1_Closing
Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
Me.Close()
End Sub
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
CalculateWH()
End Sub
Sub ClearScreen()
Dim Temp As String
Temp = mskSSN.Mask
mskSSN.Mask = ""
mskSSN.CtlText = ""
mskSSN.Mask = Temp
txtName.Text = ""
lblIncome.Text = ""
txtCurrentIncome.Text = ""
lblPrevIncome.Text = ""
lblPrevWithholdings.Text = ""
lblCurrentIncome.Text = ""
lblCurrentWithholdings.Text = ""
End Sub
Sub CalculateWH()
Dim CurrentIncome As Double
Dim PrevIncome As Double
Dim CurrentWithholding As Double
Dim TotalWithholding As Double
Dim PrevWithholding As Double
Dim TotalIncome As Double
CurrentIncome = Val(txtCurrentIncome.Text)
If IsNumeric(lblPrevIncome.Text) Then
PrevIncome = CDbl(lblPrevIncome.Text)
End If
TotalIncome = CurrentIncome + PrevIncome
If PrevIncome < 45000 Then
PrevWithholding = (PrevIncome * 0.062)
Else
'Max SST
PrevWithholding = 45000 * 0.062
End If
'For Meidicare tax
If PrevIncome < 120000 Then
PrevWithholding += (PrevIncome * 0.0145)
Else
'Max MT
PrevWithholding += 120000 * 0.0145
End If
If TotalIncome < 45000 Then
TotalWithholding = (TotalIncome * 0.062)
Else
TotalWithholding = (45000 * 0.062)
End If
'For MT
If TotalIncome < 120000 Then
TotalWithholding += (TotalIncome * 0.0145)
Else
TotalWithholding += 120000 * 0.0145
End If
CurrentWithholding = TotalWithholding - PrevWithholding
lblPrevIncome.Text = Format(PrevIncome, "Standard")
lblCurrentIncome.Text = Format(CurrentIncome, "Standard")
lblPrevWithholdings.Text = Format(PrevWithholding, "Standard")
lblCurrentWithholdings.Text = Format(CurrentWithholding, "Standard")
End Sub
Private Function GetTheFileName(ByVal TheDialog As FileDialog, ByVal TheTitle As String, ByVal TheFilter As String) As String
With TheDialog
.Title = TheTitle
.Filter = TheFilter
.ShowDialog()
Return (.FileName)
End With
End Function
Sub ReadPayrollData()
Dim Response As Integer
Dim PayData As String
Dim P0, P As Integer
Dim Temp As String
If PayrollReader.Peek() = -1 Then
MsgBox("No More Records")
ClearScreen()
Exit Sub
End If
PayData = PayrollReader.ReadLine()
P = InStr(PayData, ",")
Temp = mskSSN.Mask
mskSSN.Mask = ""
mskSSN.CtlText = Microsoft.VisualBasic.Left(PayData, P - 1)
mskSSN.Mask = Temp
P0 = P
P = InStr(P + 1, PayData, ",")
txtName.Text = Mid(PayData, P0 + 1, P - P0 - 1)
P0 = P
P = InStr(P + 1, PayData, ",")
lblPrevIncome.Text = Format(CDbl(Mid(PayData, P0 + 1, P - P0 - 1)), "Standard")
lblIncome.Text = lblPrevIncome.Text
Temp = Mid(PayData, P + 2)
If Missing(Temp) Then
Temp = "0"
End If
lblPrevWithholdings.Text = Format(CDbl(Temp), "Standard")
End Sub
Sub SavePayrollData()
Dim OutputLine As String
Dim TotalIncome, totalWH As Double
TotalIncome = CDbl(lblCurrentIncome.Text) + CDbl(lblPrevIncome.Text)
totalWH = CDbl(lblPrevWithholdings.Text) + CDbl(lblCurrentWithholdings.Text)
OutputLine = mskSSN.CtlText & ", " & txtName.Text & ", " & TotalIncome & ", " & totalWH
PayrollWriter.WriteLine(OutputLine)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim InFileName As String
Dim OutFileName As String
InFileName = GetTheFileName(cdlOpenFile, "Where is the payroll y-t-d file?", FileFilter)
OutFileName = GetTheFileName(cdlSaveFile, "Specify filename to save", FileFilter)
PayrollReader = New System.IO.StreamReader(InFileName)
PayrollWriter = New System.IO.StreamWriter(OutFileName)
End Sub
Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click
ReadPayrollData()
End Sub