Solved

Convert 24-Hour to 12-Hour

Posted on 2007-12-02
3
968 Views
Last Modified: 2013-11-07
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?
0
Comment
Question by:Ray Turner
3 Comments
 
LVL 4

Expert Comment

by:aumudin
ID: 20393988
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.
0
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 20393991
Hi rgturner,

You can use something like this....

    Date.ParseExact(1800, "HHmm", Nothing).ToString("h:mmt").ToLower

Regards,

Wayne
0
 

Author Closing Comment

by:Ray Turner
ID: 31412273
Thanks!!!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now