|
-
Mar 27th, 2000, 03:13 AM
#1
Thread Starter
Member
I cannot see why my total doesn't figure correctly.
Option Explicit
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdOutput_Click()
Dim empName As String, hrRate As String, hrWork As Single, _
grPay As String, totPay As String, fmt As String, i As Single, _
tpay As String
'display payroll report
picOutput.Cls
picOutput.Print "Payroll Report for Week ending 4/15/99"
picOutput.Print ""
picOutput.Print "Employee"; Tab(15); "Hourly Rate"; Tab(30);
picOutput.Print "Hours worked"; Tab(45); "Gross Pay"
fmt = "@@@@@@@@@@"
Open App.Path & "\Payroll.txt" For Input As #1
totPay = 0
grPay = 0
For i = 1 To 10
Input #1, empName, hrRate, hrWork
If hrWork <= 40 Then
grPay = hrWork * hrRate
ElseIf hrWork > 40 Then
grPay = (40 * hrRate) + (hrWork - 40) * (hrRate * 1.5)
End If
tpay = (grPay + totPay)
hrRate = FormatCurrency(hrRate)
grPay = FormatCurrency(grPay)
picOutput.Print empName; Tab(15); Format(hrRate, fmt); Tab(29);
picOutput.Print hrWork; Tab(42); Format(grPay, fmt)
Next i
Close #1
tpay = FormatCurrency(tpay)
picOutput.Print ""
picOutput.Print "Final Total"; Tab(15); Format(tpay, fmt)
End Sub
-
Mar 27th, 2000, 03:34 AM
#2
Junior Member
see if this helps:
Option Explicit
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdOutput_Click()
Dim empName As String, hrRate As String, hrWork As Single, _
grPay As String, totPay As String, fmt As String, i As Single, _
tpay As String
'display payroll report
picOutput.Cls
picOutput.Print "Payroll Report for Week ending 4/15/99"
picOutput.Print ""
picOutput.Print "Employee"; Tab(15); "Hourly Rate"; Tab(30);
picOutput.Print "Hours worked"; Tab(45); "Gross Pay"
fmt = "@@@@@@@@@@"
Open App.Path & "\Payroll.txt" For Input As #1
totPay = 0
grPay = 0
For i = 1 To 10
Input #1, empName, hrRate, hrWork
If hrWork <= 40 Then
grPay = hrWork * hrRate
ElseIf hrWork > 40 Then
grPay = (40 * hrRate) + (hrWork - 40) * (hrRate * 1.5)
End If
totPay = (Val(grPay) + Val(totPay))
hrRate = FormatCurrency(hrRate)
grPay = FormatCurrency(grPay)
picOutput.Print empName; Tab(15); Format(hrRate, fmt); Tab(29);
picOutput.Print hrWork; Tab(42); Format(grPay, fmt)
Next i
Close #1
tpay = FormatCurrency(totPay)
picOutput.Print ""
picOutput.Print "Final Total"; Tab(15); Format(tpay, fmt)
End Sub
-
Mar 27th, 2000, 04:26 AM
#3
Thread Starter
Member
This didn't work.
It returns a value of $290.00
My entry returns $2900.00
Should be 2935.13
-
Mar 27th, 2000, 06:47 AM
#4
Frenzied Member
Shouldn't
tpay = (grPay + totPay)
be
tpay = grPay + tPay
?
I would also define tpay as currency and convert it prior to printing it:
picOutput.Print "Final Total"; Tab(15); Format(Cstr(tpay), fmt)
-
Mar 27th, 2000, 07:14 AM
#5
Thread Starter
Member
When I try this I get an error.
I can see that it is returning tPay as
290270168354.8753...
MomOf3CollegeStudentTooMuchToDoNeverEnoughTime
Using VB6 Working Model Edition
-
Mar 27th, 2000, 11:49 AM
#6
Frenzied Member
Probably because your format string is 10 chars long and the output you're displaying is at least 17.
You've got two choices. You can post the data here or you can step thru the code and observe the value(s) of the data being read.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|