Results 1 to 3 of 3

Thread: msg on time

  1. #1

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    msg on time

    hey, ive got a command button and i want to display a message depending in the time, eg goodmoring, good evening ect.

    can any one help me out
    Code:
    Dim i As Variant
    i = Time
    If "00:00:00" > i < "03:00:00" Then
        MsgBox "GoodEarly Early Moring"
        End If
    If "03:00:01" > i < "12:00:00" Then
        MsgBox "GoodMoring"
        End If
    If "12:00:01" > i < "17:00:00" Then
        MsgBox "Good Afternoon"
        End If
    If "17:00:01" > i < "23:59:59" Then
        MsgBox "Good Night"
        End If
    thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Here is something to get you going.
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim MyTime As String
    3. MyTime = "11:30"
    4. MyTime = Format(MyTime, "hh:ss")
    5. If Time > MyTime Then
    6.    MsgBox "good afternoon"
    7. End If
    8. End Sub

  3. #3
    Lively Member nateobot's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Minnesota
    Posts
    71
    I think this is what you need.
    Might want to double check first.


    VB Code:
    1. Dim i As Variant
    2. i = Time
    3. If i < "23:59:59" Then
    4.     If i < "17:00:00" Then
    5.         If i < "12:00:00" Then
    6.             If  i < "03:00:00" Then
    7.                 MsgBox "GoodEarly Early Moring"
    8.             end if            
    9.         else
    10.             MsgBox "GoodMoring"
    11.         end if
    12.      else
    13.             MsgBox "Good Afternoon"
    14.      end if
    15. else
    16.     MsgBox "Good Night"
    17. end If

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