Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 18th, 2006, 10:17 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
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.
Reply With Quote
  #2 (permalink)  
Old September 18th, 2006, 10:23 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
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
Reply With Quote
  #3 (permalink)  
Old September 18th, 2006, 10:25 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
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.

Reply With Quote
  #4 (permalink)  
Old September 18th, 2006, 10:33 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
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
Reply With Quote
  #5 (permalink)  
Old September 18th, 2006, 10:47 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
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?

Reply With Quote
  #6 (permalink)  
Old September 18th, 2006, 11:48 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
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
Reply With Quote
  #7 (permalink)  
Old September 18th, 2006, 01:36 PM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes. Thank you.

Reply With Quote
  #8 (permalink)  
Old September 18th, 2006, 01:42 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

no problem... :)

HTH

Gonzalo
Reply With Quote
  #9 (permalink)  
Old September 19th, 2006, 12:27 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:11 PM.


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