Em um Módulo:
Código: Selecionar todos
Option Explicit
Dim T
Sub StopTimer()
On Error Resume Next
Application.OnTime T, Procedure:="Update", Schedule:=False
End Sub
Sub StartTimer()
T = Now + TimeValue("00:00:01")
Application.OnTime T, "Update"
End Sub
Sub Update()
Dim HorasT As String
Dim horas As Integer
UserForm1.LABELHORA.Caption = Format(Now, "hh:mm:ss")
UserForm1.Label1.Caption = Now + TimeValue("00:00:01")
UserForm1.Label1.Caption = Format(Now, "hh")
HorasT = UserForm1.Label1.Caption
horas = CInt(HorasT)
If horas < 12 Then
UserForm1.Label1.Caption = "Bom Dia!"
Else
If horas < 18 Then
UserForm1.Label1.Caption = "Boa Tarde!"
Else
UserForm1.Label1.Caption = "Boa Noite!"
End If
End If
UserForm1.Label1.Visible = True
Call StartTimer
End Sub
No form:
Código: Selecionar todos
Option Explicit
Dim T
Private Sub INICIAR_Click()
Application.Run "StartTimer"
End Sub
Private Sub PARAR_Click()
Application.Run "StopTimer"
End Sub
Private Sub UserForm_Initialize()
UserForm1.LABELHORA.Caption = Format(Now, "hh:mm:ss")
End Sub