Select event depending on day & time
Hey all,
Could someone suggest a good method of doing the following.
I need to fill a label with an event that is occuring depending what the time of the day is. For example, if I have a text file like this:
Monday:
0=EVENT1
1=EVENT1
2=EVENT1
3=EVENT2
4=EVENT3
The file includes each day of the week and the numbers are related to what time it is.
SO, what I need to do is be able to select the correct day and then the correct event (dependant on the time) and display the result in a label!
Any ideas ?
Re: Select event depending on day & time
use this:
VB Code:
Select Case Weekday(Now, vbMonday)
Case 1
MsgBox "Today is Monday", vbInformation
Case 2
MsgBox "Today is Tuesday", vbInformation
Case 3
MsgBox "Today is Wednesday", vbInformation
Case 4
MsgBox "Today is Thursday", vbInformation
Case 5
MsgBox "Today is Friday", vbInformation
Case 6
MsgBox "Today is Saturday", vbInformation
Case 7
MsgBox "Today is Sunday", vbInformation
End Select
Re: Select event depending on day & time
Also for time and date, use these functions:
Hour(Now)
Minute(Now)
Second(Now)
Day(Now)
Month(Now)
Year(Now)
Re: Select event depending on day & time
If you storing data in the file then it wouldn't be best way all arround - I suggest to "switch" to small database like MS Access.
By doing so you will appreciate the difference and flexibility db method offers.
If you decide so then rest will be a breeze ... you may however need to learn some db processing basics. :wave:
Re: Select event depending on day & time
Thanks guys! A DB, never thought of that option! As the events will be updated on a weekly basis.
Re: Select event depending on day & time
Re: Select event depending on day & time
Quote:
Originally Posted by Griffo
... As the events will be updated on a weekly basis.
... and that's the beaty of using database - you may keep existing data for historical purpose for as long as you need it without having any needs to update/delete existing so you can easy report on everything that did happend or will happend.