IsDate flaw/bug ?

  • Thread starter Thread starter Alex Glass
  • Start date Start date
A

Alex Glass

In my project I'm using trying to use the IsDate function to check if the
user correctly formated the date in a textbox. The amount of time it takes
for the function to return a value initially is over 3 seconds.all
subsequent calls to the function take a fraction of a second. Does anyone
have an idea what might be going on? I supply some testing code i created
with the output below:

Dim t1, t2 as Long
t1 = Now.Ticks
If IsDate("12/50") Then Debug.WriteLine("this doesnt happen")
t2 = Now.Ticks
Debug.WriteLine("elapsed: " & ((t2 - t1) / Math.Pow(10, 7)))

t1 = Now.Ticks
If IsDate("12/50") Then Debug.WriteLine("this also doesnt happen")
t2 = Now.Ticks
Debug.WriteLine("elapsed: " & ((t2 - t1) / Math.Pow(10, 7)))

------------------------------------------------------------------------------
Output is:
elapsed: 3.296875
elapsed: 0

Any clarification would be greatly appreciated

-Alex
 
Hi Alex,

I'm guessing this function uses a try/catch block inside which can be
costly the first time. I may be wrong though, and in any case three
seconds seems long.
 
Back
Top