?
Solved

Convert 24-Hour to 12-Hour

Posted on 2007-12-02
3
Medium Priority
?
981 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 48

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

839 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