Hi
I'm look to format an output of a calculation into time using VB and it's driving me nuts does anyone have any ideas based on the function below?
Example Values
TotalMinutes = 90.5
Distance = 16
PaceCalc = 5.66
I want to display pace calc as minutes and second not just minutes so rather than getting a result of 5.66 minutes i want a result of 5 Minutes 40 Seconds (IE 0.66 times 60 = 39.6 (40 Rounded)). How can i isolate the digits to the right of the decimal place and times these by 60 rather than the whole result?
I'm look to format an output of a calculation into time using VB and it's driving me nuts does anyone have any ideas based on the function below?
Example Values
TotalMinutes = 90.5
Distance = 16
PaceCalc = 5.66
I want to display pace calc as minutes and second not just minutes so rather than getting a result of 5.66 minutes i want a result of 5 Minutes 40 Seconds (IE 0.66 times 60 = 39.6 (40 Rounded)). How can i isolate the digits to the right of the decimal place and times these by 60 rather than the whole result?
Code:
Private Function PaceCalc(ByVal Hours As Integer, ByVal Minutes As Integer, ByVal Seconds As Integer, ByVal Distance As Decimal) As Double ' Function Calculates average pace from data supplied from textboxes on form Dim Time As New TimeSpan(Hours, Minutes, Seconds) Dim TotalMinutes As Double = Time.TotalMinutes PaceCalc = TotalMinutes / Distance End Function
Comment