Link to home
Start Free TrialLog in
Avatar of RayT
RayTFlag for United States of America

asked on

Convert 24-Hour to 12-Hour

Is there a built-in function in Visual Basic 2005 that converts for example 1000 to 10:00a or 1800 to 6:00p?  If not,  how do I do this using Visual Basic 2005?
Avatar of aumudin
aumudin
Flag of United States of America image

Not sure if there is a function but if you have to write your own code id do something like (idk if this is neccesarrly the best way about it)

if tempTime >= 1300 then
tempTime = (tempTime - 1200)
tempString = tempTime.tostring
tempString = tempString.insert(2,":") & "PM"
else
tempString = tempTime.tostring
tempString &= "AM"

If this dont work its something very simular and ill try it in the morning to get it perfect for you im on my laptop which I dont have vs instealled on.
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia 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
Avatar of RayT

ASKER

Thanks!!!