Link to home
Start Free TrialLog in
Avatar of Ross Wise
Ross WiseFlag for United States of America

asked on

string literal for half-a-second

Is there an acceptable string literal in the VBA (Access 2013) TimeValue function to express fractions of a second?
In this particular case a Half-Second.

TU_HALF_SECOND = TimeValue("00:00:00.5")         ' Type mismatch error

As a work-around I have calculated it mathematically from a value of one-second:

   TU_HALF_SECOND = TimeValue("00:00:01")         '  The smallest (non-zero) literal I have found that works
   TUVal_HALF_SECOND = CDbl(TU_HALF_SECOND)
   
   TUVal_HALF_SECOND = TUVal_ZERO_SECONDS + (TUVal_HALF_SECOND - TUVal_ZERO_SECONDS) / 2  
                                                                      '  Zero seconds obtained via TimeValue("00:00:00")    ::     I'm aware that this may be redundant
   TU_HALF_SECOND = CDate(TUVal_HALF_SECOND)

So this is not an emergency, I'm just curious.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ross Wise

ASKER

Thank you both.
You are welcome!

/gustav