Solved

Convert 24-Hour to 12-Hour

Posted on 2007-12-02
3
971 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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