Results 1 to 13 of 13

Thread: Adding up input boxes

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    Tucson, AZ
    Posts
    6
    I am creating a daily payroll program that allows an employ to come in and out 6 times a day. When I Add up the hours the employee came and went out it does not compute correctly.
    Example: In at 8am - Out at 10am = 2 hrs worked. The program is totallying up the hours to give me 18hrs. How and what do i need to do to get the correct hours to reflect. Any suggestions would be helpful.

    Thanks
    Rey

  2. #2
    Guest
    Use the Val Function.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    Tucson, AZ
    Posts
    6
    Originally posted by Matthew Gates
    Use the Val Function.
    Thank you for your reply;
    I am using the Val funtction. Actually I think I found the answer but I am not all the way there. My code actually looks like this:

    Dim In1 as SINGLE
    Dim Out1 as Single
    In1 = Val(txtIn1.Text)
    Out1 = Val(txtout1.Text)
    pictotal1.Print In1 - Out1

    I had the last function adding the two so that is why I was getting the big numbers. I just put in the minus function but I can't get my program to display the if I put in the colon( to display hours. Any more sugestions?

    Thanks

    Rey

  4. #4
    Addicted Member
    Join Date
    Aug 2000
    Location
    Croatia
    Posts
    200

    Question

    In1 - Out1???

    I know I'm not Einstien, but shouldn't it be Out1 - In1? Like, the time at which the person left, minus the time he got in?

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    Tucson, AZ
    Posts
    6
    Originally posted by Arcom
    In1 - Out1???

    I know I'm not Einstien, but shouldn't it be Out1 - In1? Like, the time at which the person left, minus the time he got in?
    Thank You!

    We are geting closer. It gives me the correct time now but I am still not able to put in a number with a colon (8:00) and get the correct out put. It does not give me the correct hours if I enter 8 from 10:15 such as( i.e.,1.34).

    Any more suggestions asnyone?
    Rey

  6. #6
    Guest
    Haven't any of you guys heard of the DATEDIFF function?

    Designed specifically for your problem.

    Code:
    Hours_Worked = datediff("h", in1, out1)

  7. #7
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up

    Well, wossname method is good, but it may also calculate incorrectly. Because may not all employee will check in/out sharp at 8am or 10am rite.

    So, it will be more accurate is you get the time dufferent between the check in/out time in second, then only start your payroll algorithm.

    Code:
    Hours_Worked = datediff("s", in1, out1)

  8. #8

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    Tucson, AZ
    Posts
    6
    Originally posted by Chris
    Well, wossname method is good, but it may also calculate incorrectly. Because may not all employee will check in/out sharp at 8am or 10am rite.

    So, it will be more accurate is you get the time dufferent between the check in/out time in second, then only start your payroll algorithm.

    Code:
    Hours_Worked = datediff("s", in1, out1)
    Thank You all for your response.
    I will give it a try.
    Rey

  9. #9
    Guest
    Chris, I was hoping lunar could work that out for him/herself I didn't intend it to be a perfect solution

    Anyway why not use minutes instead of seconds, (most companies round down to the nearest couple of minutes anyway)? The code for which is "n" when using datediff.

  10. #10

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    Tucson, AZ
    Posts
    6
    Originally posted by wossname
    Chris, I was hoping lunar could work that out for him/herself I didn't intend it to be a perfect solution

    Anyway why not use minutes instead of seconds, (most companies round down to the nearest couple of minutes anyway)? The code for which is "n" when using datediff.
    Again, thanks for the responses and I was intending on using minutes. I saw that DateDiff function on a couple of example I found while doing my research on this problem. Unfortunately, I am new to this and the book that was required for this class does not mention that function. What's even worse is that this project is assigned and that function would be essential.

    Again Thanks,

    Rey

  11. #11
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Lunar1, perhaps the following url can be the reference point for your in your assignment or your future prospect:
    [*]Planet Source Code[*]MSDN Online Library[*]VB XML[*]CodeGuru

    above juz some of my bookmark and hope it can make sense to you.

    Chris

  12. #12

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    Tucson, AZ
    Posts
    6
    Originally posted by Chris
    Lunar1, perhaps the following url can be the reference point for your in your assignment or your future prospect:
    [*]Planet Source Code[*]MSDN Online Library[*]VB XML[*]CodeGuru

    above juz some of my bookmark and hope it can make sense to you.

    Chris
    Thanks to all of you who responded. I got it figured out.
    Rey

  13. #13
    Guest
    Lunar1: Hi, don't wish to be rude, but could you possibly quote people less frequently, its a bit confusing when searching for a specific posting in a long thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width