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
abangbataxAsked:
Who is Participating?
 
hongjunConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.