I may be being really stupid here, but my brain’s gone blank.
I’ve got a slider bar (which uses Int32 values) but I want to use it to select a position in a music song (mm.ss)
I also want to output the value that the slider is displaying in to a label above it, so it’s easier to see what the slider is set to.
Anyone have any suggestions?
I thought of trying to convert the int value in to a decimal then dividing by 60.
I’m doing this in C# by the way.
What does the
intvalue represent? If it’s the number of seconds through the song, you should use:Using a
decimalwould be a really bad idea – a format with a number of seconds isn’t the same as a fractional number of minutes. For example, 10.50 minutes as a fractional number of minutes is 10 minutes and 30 seconds, not 10 minutes and 50 seconds, which is what you want as far as I can tell.TimeSpanis the natural way of representing a time duration in .NET… which is why that’s the type which supports formatting in minutes and seconds.