 |
| 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
|
|
|
|

September 18th, 2006, 10:17 AM
|
|
Registered User
|
|
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

September 18th, 2006, 10:23 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
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
|
|

September 18th, 2006, 10:25 AM
|
|
Registered User
|
|
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

September 18th, 2006, 10:33 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
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
|
|

September 18th, 2006, 10:47 AM
|
|
Registered User
|
|
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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?
|
|

September 18th, 2006, 11:48 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
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
|
|

September 18th, 2006, 01:36 PM
|
|
Registered User
|
|
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes. Thank you.
|
|

September 18th, 2006, 01:42 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
no problem... :)
HTH
Gonzalo
|
|

September 19th, 2006, 12:27 PM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |