"Carol Shu" <(E-Mail Removed)> wrote in message
news:8CBF37EE-4B24-4392-B76A-(E-Mail Removed)...
> question: this on activate event works great, but when it is morning
> hours,
> it show "good evening", then in the evening hours it show "good morning",
> can't figure out why, please help.
>
> Private Sub Form_Activate()
> If Time() < 0.5 Then
> [lblMorning].Visible = True
> [lblAfternoon].Visible = False
> [lblEvening].Visible = False
>
> ElseIf Time() > 0.5 And Time() < 0.75 Then
> [lblMorning].Visible = False
> [lblAfternoon].Visible = True
> [lblEvening].Visible = False
>
> ElseIf Time() > 0.75 Then
> [lblMorning].Visible = False
> [lblAfternoon].Visible = False
> [lblEvening].Visible = True
> End If
> End Sub
I'm not sure what you're trying to do with the Time() function, but as far
as I can tell it returns the actual time of day, not a number between 0 and
1. I'd suggest doing something like this:
If Hour(Time()) <= 12 Then
' morning
Elseif Hour(Time()) > 12 And Hour(Time()) < 18 Then
' afternoon
Else
' evening
End If
Carl Rapson
|