Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time and Date functions return single digit

Status
Not open for further replies.

jimlee

Programmer
Jan 27, 2001
213
GB
Hi,
Hopefully this is a simple one but i can't fingure it out for the life of me.

i have this simple line...
msgbox Time
which returns the single digit of 9 instead of 9:10:11
the same thing happens with the date function.

This is only happening with excel vba. When i try it in Access it is fine.

Any ideas appreciated as this is one of those small annoying problems that shouldn't be eating up my development time!

thanks

jimlad

"There's this thing called being so open-minded your brains drop out." -
 
Have you tried this ?
MsgBox Time$

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Just tried Time$ and got a compilation error...
"Type-declaration character does not match declared data type"

jimlad

"There's this thing called being so open-minded your brains drop out." -
 
Seems like you have declared a variable named Time ...
What about this ?
MsgBox VBA.Time$

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
ah, yes, i had Time declared as a public enum with a value of 9. i didn't see it as it was in a different module. I have changed the public to private and now all is well! (bad naming of variables i know!)

Thanks for your help. much appreciated as always.

jimlad

"There's this thing called being so open-minded your brains drop out." -
 

have this simple line...
msgbox Time
which returns the single digit of [red]9[/red]

i had Time declared as a public enum with a value of [red]9[/red]

[sub]my emphasis[/sub]

Did that not give you a hint, even before posting?

Would that not have been a relevent piece of information to disclose right up front?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Skip,
Firstly, if you read the thread you will realise that I hadn't seen the enum declaration at first, so no it wouldn't have given me a hint before posting.
Had I reasised that i had declared this variable in a different module then yes, of course it would have given me a hint and i wouldn't have had to post anything.

Secondly, if i had have had this information 'right up front' then i would have realised my first point and again, wouldn't have had to post this thread.





jimlad

"There's this thing called being so open-minded your brains drop out." -
 
Honest, I am not trying to be overly critical.
i have this simple line...
msgbox Time
A basic and simple debugging tool is using Find.

Obvious fact: "Time" is giving you something wrong.

Obvious effort to fix: Edit > Find and look for "Time"

Bingo.

"A little piece of heaven
without that awkward dying part."

advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)

Gerry
 
Look, I used find to look for "Time" and it gave me nothing as I didn't select the 'Current project' option, the 'current module' option was checked by default. To be honest most the vba that i write is only in 1 module anyway so it wasn't the first thing i would have thought of.

I did try the usual search on the website and google first, and yes, when i realised the answer i felt a bit stupid for not realising the answer before i posted as it is a basic schoolboy error but these things happen.


I honestly didn't mean to waste anyones time! I'm sorry if I did.

jimlad

"There's this thing called being so open-minded your brains drop out." -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top