I was wondering how you would display the time in hour/minutes/seconds and then depending on what time of the day it is, it displays the relevant label e.g. Good morning, good afternoon etc


Recommended Answers

All 3 Replies

I have used 2 timers, one to show the time, a second to check for morning or afternoon -

Private Sub Timer1_Timer()

Label1.Caption = Format$(Time, "hh:mm:ss AM/PM")
End Sub

Private Sub Timer2_Timer()

If Hour(Now) >= 12 Then
Label1.ForeColor = vbBlue
End If
End Sub

This should answer your question.

currentTime = Format(Now(), "hh:mm")

If currentTime > "12:00" Then
    Label12.Caption = "Good Afternoon"
    Label12.Caption = "Good Morning"
End If

I ended up using this, thanks anyway

No problem. Your code explains more of what you needed. nice.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.