Results 1 to 3 of 3

Thread: Need some help here! Time difference calculations

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2012
    Posts
    15

    Question Need some help here! Time difference calculations

    Hello there, I'm having some trouble with a program I'm trying to develop. I know some basics of visual basic(haha) but nothing very advanced and hopefully you guys will be able to help me out. I work at Kroger and what I am trying to do is develop a program for my work to make writing out break schedules and lot hours (where you have an hour to push buggies in) easier for the front office managers. The function of this progam need to go like this:

    1. Select bagger from combobox (a name EX: Chris)

    2. enter work schedule for the day into say a text box? (Ex: 9:00 PM - 5:00 PM)

    3. Click a command button to do the calculations

    4. what it needs to calculate - at Kroger our schedules are always based on 15 minute intervals (ex: 9:00, 9:15, 9:30, 9:45, 10:00 and so on)

    It needs to calculate the total number of hours worked taking into the account of AM/PM.

    It needs to be able to schedule breaks for each bagger. Our break schedule goes like this: for a 4 hour shift you get one break, for a 6:15 shift you get two breaks, and an 8 hour shift you get two breaks and a lunch. The breaks are spread out equally throughout the shift (ex: 12:00AM-4:00PM the break would be at 2:00PM, 12:00AM-6:15PM the breaks would be around 3:00PM-3:30PM since there is no middle based on the 15 minute interval system, 12:00AM-8:00PM the breaks would be around 2:45, a 30 minute lunch at 4:15, and another break at 6:30) The breaks cant always be an exact middle but close enough is fine.

    5. It needs to be able to schedule lot hours from 7:00 AM to 11:00 PM, each bagger getting at least one lot and some getting two (there is about 10 different baggers a day)
    I believe I can handle step 5 but I really need help with step 4 because I have no idea on how to calculate the time differences and schedule breaks even throughout shifts.

    as far as display, all the calculations can go into textboxes that are read only.
    Any help will be appreciated!

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: Need some help here! Time difference calculations

    Why use textboxes as Read Only? That only frustrates users (especially the ones that don't read instructions....which is ALL of them). Use a label to display information that the user can't change. Use textboxes to display information that the user CAN change.

    You talk about shifts as if they were fairly fixed in duration at first, then as if they were flexible. If they are fixed, you probably wouldn't have any problem, so I would guess that they are flexible. It's more like a clocking in and clocking out, though you may know when you will be clocking out when you clock in, so it isn't quite the same.

    I would suggest a DateTimePicker in Time mode for both the start and the end. Put that information into Date variables (the .Value property of the DTP is a date already, so you might not even need any other variable). You can then do something like:

    (Date1 - Date2).TotalHours

    to get the number of hours , which should allow you to figure whether there is one or two breaks. There are other TotalX functions that might be even more useful, but TotalHours may be best. Once you have that total interval, you could divide it into the breaks, then add hours (Date1.AddHours) to figure out when the breaks should happen.

    Those are general pointers, which is about all I feel up to at the moment, but it sounds like that might point you right.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2012
    Posts
    15

    Re: Need some help here! Time difference calculations

    Thank you very much, I will give it a shot and I'm sure those functions will help greatly.

Tags for this 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