Clear a date variable
Hello,
Here is my problem.
I declare my variables:
Public p_prev, r_prev, p_real, r_real As Date
Then I initialize them:
p_prev = Empty
p_real = Empty
r_prev = Empty
r_real = Empty
But as soon as I query them, here is the result:
p_prev =
p_real =
r_prev =
r_real = 00:00:00
And I don't understand at all why "r_real" returns "00:00:00"
Do you have any idea why or how this is happening?
Thank you
Configuration: Windows Vista / Firefox 35.0
Here is my problem.
I declare my variables:
Public p_prev, r_prev, p_real, r_real As Date
Then I initialize them:
p_prev = Empty
p_real = Empty
r_prev = Empty
r_real = Empty
But as soon as I query them, here is the result:
p_prev =
p_real =
r_prev =
r_real = 00:00:00
And I don't understand at all why "r_real" returns "00:00:00"
Do you have any idea why or how this is happening?
Thank you
Configuration: Windows Vista / Firefox 35.0
2 answers
-
ContributorHello,
As you definedr_real As Date
your variable is in date format: this is only normal because a zero date is empty.
--
Always zen
Perfection is attained, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupéry -
ModeratorHello,
I would like to add to gbinforme's response (greetings, by the way) that this declaration:Public p_prev, r_prev, p_real, r_real As Date
is equivalent to:Public p_prev As Variant, r_prev As Variant, p_real As Variant, r_real As Date
In VBA, you need to specify the type for each variable. So:Public p_prev As Date, r_prev As Date, p_real As Date, r_real As Date
That's why you get:p_prev =
p_real =
r_prev =
r_real = 00:00:00
Before, I could never finish my sentences... but now I-
-
Moderator@gbinformeHi gbinforme,
No problem.
The answers complement each other, and the main thing is that the issue is resolved.
See you later
Have a good day
-