Find if times is between 2 times.

talkster5

New member
Joined
May 13, 2009
Messages
2
Programming Experience
Beginner
Hi,
I have just started using vb.net and I have a checked list box with times throughout the day shown as

00:00 - 00:14
00:15 - 00:29
00:30 - 00:44
00:45 - 00:59

What I am trying to find is a way to get the current time and find which list item it fits into. What I think I need to do is to first of all get the current time and then go through the list splitting each item into 2 times and seeing if the current time fits. For example:

Split the item 00:00 - 00:14 to 00:00 and 00:14 and then check if the current time is more than 00:00:00 but less than 00:14:59 and if so do certain task.

However my problem is I do not know how to go about taking each list item and splitting it into 2 separate times so I can check between them?

I hope that all makes sense.
 
You need String.Split() and you can access the items in the listbox either via index Listbox.Items(index) or you cycle with
for each itm as String in Listbox.items

similar to
[vb]
dim spl() as String
for each itm as string in mylistbox.items
spl=itm.split(" - ")
' check time
next
[/vb]
 
Back
Top