Android Question Conversion in a clock format

AlexDan

Member
I use the time counter in seconds in B4A using the timer.
How to translate numbers in label.Text in clock format: minutes: seconds?
Attempt to apply code:
-------------------
Sub Convert Milliseconds to String (T AS LONG) AS String
Dim Hours, Minutes, Seconds AS INT
Hours = T / DateTime.ticksperhour
MINUTS = (T mod datetime.ticksperhour) / datetime.ticksperminute
Seconds = (T mod datetime.ticksperminute) / datetime.tickspersecond
Return $ "$ 1.0 {Hours}: $ 2.0 {minutes}: $ 2.0 {seconds}" $
End Sub.
--------------------
gives an error message ?

The code :
--------------------
'Converts Milliseconds to M: SS Format.
Sub ConvertTotimeFormat (MS AS INT) AS String
Dim Seconds, Minutes AS INT
Seconds = Round (MS / 1000)
Minutes = Floor (Seconds / 60)
Seconds = Seconds MOD 60
Return NumberFormat (Minutes, 1, 0) & ":" & NumberFormat (Seconds, 2, 0) 'Ex: 3:05
End Sub.
--------------------
Does not solve the desired task and works only with MediaPlayer.

Can I give an example of solving this problem?
 

Mahares

Expert
Licensed User
Longtime User
Can I give an example of solving this problem?
1. You need to use code tags to post code. It will look a lot better.
2. You say there is an error, but you do not show the error.
3. One place you spell: minuts, and in another minutes. You have to be consistent. I am not sure if you are making typos mistakes or copying and pasting
 
Upvote 0
Top