time range in 24h format


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?

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
      worker = setting.text29.text
end if

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.