Results 1 to 7 of 7

Thread: Select event depending on day & time

  1. #1

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    34

    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 ?

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Select event depending on day & time

    use this:

    VB Code:
    1. Select Case Weekday(Now, vbMonday)
    2.         Case 1
    3.             MsgBox "Today is Monday", vbInformation
    4.         Case 2
    5.             MsgBox "Today is Tuesday", vbInformation
    6.         Case 3
    7.             MsgBox "Today is Wednesday", vbInformation
    8.         Case 4
    9.             MsgBox "Today is Thursday", vbInformation
    10.         Case 5
    11.             MsgBox "Today is Friday", vbInformation
    12.         Case 6
    13.             MsgBox "Today is Saturday", vbInformation
    14.         Case 7
    15.             MsgBox "Today is Sunday", vbInformation
    16.     End Select

  3. #3
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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)

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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.

  5. #5

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    34

    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.

  6. #6
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Select event depending on day & time

    No problem

  7. #7
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width