[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

time range in 24h format

hi,

how to code time range in vb?

ex.

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?

thanks
0
abangbatax
Asked:
abangbatax
1 Solution
 
hongjunCommented:
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
else
      worker = setting.text29.text
end if


hongjun
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now