Solved

Second to hours and minutes

Posted on 2004-08-28
3
251 Views
Last Modified: 2010-04-17
i am currently using this code to show time in hours and minutes from seconds. (ttime = seconds) Every 60 seconds it i make it refresh itself. It works great, the only problem that i see with it is that sometimes when its about to change from hole hours. This is what happens. It displays 02:00 then it displays (60s after) 01:00 then (60s after) 01:59. Another example would be 01:00 then 00:00 then 00:59. How can i fix this? Vb6

h = Int(Val(ttime) / 3600)
m = Int((Val(ttime) / 60) Mod 60)
If h < 10 Then
h = "0" & h
End If
If m < 10 Then
m = "0" & m
End If
0
Comment
Question by:DARKSAGES
[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
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
DarkoLord earned 500 total points
ID: 11922518
Hi, try this (it also converts to days):

            Dim seconds As Long
            Dim d As Long 'days
            Dim h As Long 'hours
            Dim m As Long 'minutes
            Dim s As Long 'seconds

            seconds = 86401 'one day, zero hours and mins and one sec

            If (seconds >= 86400) Then
                d = seconds \ 86400
                seconds = seconds Mod 86400
            End If

            If (seconds >= 3600) Then
                h = seconds \ 3600
                seconds = seconds Mod 3600
            End If

            If (seconds >= 60) Then
                m = seconds \ 60
                seconds = seconds Mod 60
            End If
            s = seconds

Darko
0
 

Author Comment

by:DARKSAGES
ID: 11922797
Thanx, for the quick answer. That was really easy but i have something due really soon and i cant think straight.
0
 
LVL 22

Expert Comment

by:DarkoLord
ID: 11922823
You're welcome

Darko
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn different types of Android Layout and some basics of an Android App.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

752 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