|
-
Feb 26th, 2000, 12:43 PM
#1
Thread Starter
Junior Member
This is what i want to do...
Im making an mp3 player, and i use the current position * the total length of the song divided by 100 which gives me the number it would be on. But the numbers are like 97.34 , and i just wanted to know how i could just convert that to 01:37. I tried all sorts of stuff, but what I tried didnt work for me. Any suggestions? (if you are going to say , just run a timer that counts how long the song has been playing, i dont want to do that because if the user fastforwards or rewinds in the song, it will be totally off.)
-
Feb 26th, 2000, 01:04 PM
#2
Fanatic Member
If you say that 97.34 equals to 1 minute and 37 seconds then I can assume that you don't care about the decimal value. If that's the case then use this code:
Code:
Dim Number
Dim inMinutes As Integer
Dim inSeconds As Integer
Number = 97.34
inMinutes = Number \ 60
inSeconds = Number - (inMinutes * 60)
MsgBox "Minutes: " & inMinutes & vbCrLf & "Seconds: " & inSeconds
I hope that this is what you mean 
Edited by QWERTY on 02-27-2000 at 01:06 AM
-
Feb 26th, 2000, 01:06 PM
#3
New Member
decimals to minutes and seconds
take the integer value of the number divided by 60
This gives the number of minutes
int(157.5/60) = 2
subtract this integer number times sixty from the original number
157.5 - int(157.5/60)*60 = 37.5
Present it as a string
str$(int(157.5/60)) & ":" & str$(157.5-int(157.5/60)*60)
gives you 2:37.5
Or it should if I haven't made a stupid typo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|