A 1 Line Seconds To Minutes
This is a function to make seconds into minutes with just one line of code! It's completely commented and very easy to understand. I've seen some other one's that were like 20 or 30 linez long so i made this one. Very good for an mp3 player. I have more lines of comments than i do code :/
Original Author: Feet
Assumptions
you can have decimals at the end of your seconds like "126.33467" it would round that to "02:06" anything .5 or under round down, anything .5 or up rounds up.
Returns
It returns "00:00" in minutes then seconds like "02:52" after u put in 172.
API Declarations
u don't even have to dim anything!
Code
Function SecsToMins(Secs As Integer)
If Secs < 60 Then SecsToMins = "00:" & Format(Secs, "00") Else SecsToMins = Format(Secs / 60, "00") & ":" & Format(Secs - Format(Secs / 60, "00") * 60, "00")
'if the seconds are less than 60 it will put a "00:" in front of it and the seconds formatted so if it was 6 seconds then it would be 06
'using format is pretty helpful
'if the seconds are 60 or are more than 60 it will
'divide the amount of seconds by 60 to get minutes
'then comes the harder to understand part(for some people)
'to get the seconds you have to format your seconds by 60 so there are no decimals. Then you multiple that by 60 and take that number away from the total seconds
'it took me awhile to figure out that i needed the format in the middle of finding the seconds.
End Function
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.