Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
How compare the actual date and time with a variable create in VB macro?
I tried this code, but the result is always "exit" independing what my test time.
Sub testa_horario()
vDateAtual = now()
vDate = date()&" 11:00:00"
if vDateAtual > vDate then
msgbox("run macro II")
else
msgbox("exit")
End if
End sub
Thanks!
This should do it:
Sub testa_horario()
vDateAtual = Now()
vDate = cdate(date()&" 11:00:00")
if vDateAtual > vDate then
msgbox("run macro II")
else
msgbox("exit")
End if
End sub
To assign variables use Set (or Let) so:
Let vDateAtual = now()
For the difference between Let and Set see e.g.
Thank you, but I need create and compare the variables in a macro, no in the load script.
This should do it:
Sub testa_horario()
vDateAtual = Now()
vDate = cdate(date()&" 11:00:00")
if vDateAtual > vDate then
msgbox("run macro II")
else
msgbox("exit")
End if
End sub
It works! Thank you!