Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 18th, 2006, 10:17 AM
Registered User
 
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Converting number to hh:mm

I have a number (it's currently the amount of minutes) that I need to convert to hours and minutes. for example, I have 123 minutes, but need it to read 2 hrs, 3 minutes.

I hope this is an easy one.
 
Old September 18th, 2006, 10:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

unless any one have a better idea...

divide the minutes by 60 and you will have the total of hours, and the rest will be the total of minutes...

HTH

Gonzalo
 
Old September 18th, 2006, 10:25 AM
Registered User
 
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The rest actually wouldn't be the total number of minutes. It would be the number of minutes represented in tenths. For example, .50 instead of 30 minutes.

 
Old September 18th, 2006, 10:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

nop.. that will be if you don't do the division with integers and use the comma part as the minutes...

the rest of an integer division will be the minutes...

123/60= 2 and 3 minutes (the rest)

HTH

Gonzalo
 
Old September 18th, 2006, 10:47 AM
Registered User
 
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, maybe I'm confused. When I do that, for example I did 10791 minutes and divided it by 60 and came up with 179.85. That's obviously not what you're telling me to do, so we're am I going wrong?

 
Old September 18th, 2006, 11:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

maybe b/c English is not my first languaje I'm explained it wrong...

when you divide 10791/60 it will came out with 179 (integer type)...

the mod of that division is the rest (the diference b/t 10791 and 179*60) = 51...

did I explain it better???

HTH

Gonzalo
 
Old September 18th, 2006, 01:36 PM
Registered User
 
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes. Thank you.

 
Old September 18th, 2006, 01:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

no problem... :)

HTH

Gonzalo
 
Old September 19th, 2006, 12:27 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To clarify: You can use the MOD operator to get your result for the minutes:

debug.print 10791 MOD 60

should print out 51 to the immediate window.


Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert seconds to HH:MM:SS bph SQL Server 2000 11 July 31st, 2009 01:53 PM
converting HH:MM to HH.MM nasirmunir PHP How-To 5 July 11th, 2008 01:33 PM
Convert time in seconds to hh:mm:ss 41509331 C++ Programming 0 March 18th, 2008 04:43 AM
Convert Seconds to HH:MM:SS jpillonel Crystal Reports 0 December 17th, 2003 09:20 AM
validation of [HH]:mm beastwood_uk Excel VBA 3 August 10th, 2003 08:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.