for x = 1 to 3
employee = InputBox("Enter employee#")
hoursworked = InputBox("Enter hoursworked")
payrate = InputBox("Enter pay rat")
print hoursworked,payrate,employee,hoursworked *payrate
next x
Printable View
for x = 1 to 3
employee = InputBox("Enter employee#")
hoursworked = InputBox("Enter hoursworked")
payrate = InputBox("Enter pay rat")
print hoursworked,payrate,employee,hoursworked *payrate
next x
You want it to print on a form?
How do I get it to pop up a messagebox where I can click OK
msgbox ("Your pay is: " & format(hoursworked *payrate, "$$$.00")
Dim a
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
For x = 1 To 3
employee = InputBox("Enter employee#")
hoursworked = InputBox("Enter hoursworked")
payrate = InputBox("Enter pay rat")
a = hoursworked * payrate
MsgBox "hoursworked, paypayrate, employee"
MsgBox a
Next x
End Sub
nonono!
like so:
VB Code:
Dim a as integer dim exployee as string dim hoursworked as integer dim payrate as integer Private Sub Command1_Click() End End Sub Private Sub Form_Load() employee = InputBox("Enter employee#") hoursworked = InputBox("Enter hours worked") payrate = InputBox("Enter pay rate") a = hoursworked * payrate MsgBox "hoursworked, paypayrate, employee " & a End Sub
VB Code:
Dim a As Integer Dim exployee As String Dim hoursworked As Integer Dim payrate As Integer Private Sub Command1_Click() End End Sub Private Sub Form_Load() For x = 1 To 3 employee = InputBox("Enter employee#") hoursworked = InputBox("Enter hoursworked") payrate = InputBox("Enter pay rat") a = hoursworked * payrate MsgBox "hoursworked, paypayrate, employee " & a Next x End Sub
I run and it works good.
I agree with dos5731 because the original post has to input 3 employees.Quote:
Originally Posted by dos5731
"a" should not be integer - it should be currency. Actually, they all need to be currency - do not use DOUBLE or SINGLE!Quote:
Originally Posted by dos5731
a = hoursworked * payrate should be a = round(hoursworked * payrate,2). And be consistent - rounding errors are a nightmare in commercial payroll development.
MsgBox "hoursworked, paypayrate, employee " & a should be
MsgBox "hoursworked, paypayrate, employee " & Cstr(a)
Respect your datatypes and do not allow VB to coerce them - always wrap in a function to match all datatypes in an expression.
With that said:
hoursworked = CCur(InputBox("Enter hoursworked"))
You will need some kind of error trapping - this can blow up if odd values (non numeric) are entered.