time range in 24h format

Posted on 2007-07-28
Last Modified: 2009-12-16

how to code time range in vb?


i got 3 workers, named A, B, and C

A work from 8 AM to 4 PM
B work from 4 PM to 12 AM
C work from 12 AM to 8 AM

what i want is a string called "worker" will automatically change depend on the time

here my code ( i guess its wrong )

dim worker as string

if time >= "08:00" and time <= "16:00" then worker = setting.text28.text
if time >= "16:00" and time <= "00:00" then worker = setting.text29.text
if time >= "00:00" and time <= "08:00" then worker = setting.text30.text

how to code the correct one?

Question by:abangbatax
    1 Comment
    LVL 33

    Accepted Solution

    try this

    if hour(time) > 8 and hour(time) <= 16 then
          worker = setting.text28.text
    elseif hour(time) > 0 and hour(time) <= 8 then
          worker = setting.text30.text
          worker = setting.text29.text
    end if


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now