by RDM Custom Computing (1 Submission)
Category: Math/Dates
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Thu 29th March 2001
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
This function will return a string: listing Days, Hours, and Minutes, when given a total number of minutes.
' Created by Don Mays 3-29-01
' RDM Custom Computing, Grand Island, NE
' [email protected]
' This function will return a string listing
' the number of hours, days, and minutes
' such as '4 days; 15 hours; 27 minutes'
' when passed a value of TOTAL MINUTES.
' The datediff() function can be used to pass a value to this.
Dim minz, hrz, dayz As Long
Dim daytime, hourtime, mintime, eltime As String
minz = 0 : hrz = 0 : dayz = 0
hrz = Int(mins / 60) ' Returns the number of hours
If hrz > 23 Then
dayz = Int(hrz / 24) ' Returns the number of days
If dayz = 1 Then
daytime = "1 day; " ' Set proper 'days' string
Else
If dayz = 0 Then
daytime = ""
Else
daytime = dayz & " days; "
End If
End If
hrz = hrz - (dayz * 24)
End If
' Set proper 'hours' string
If hrz = 1 Then hourtime = "1 hour; " Else hourtime = hrz & " hours; "
mins = mins - (dayz * 1440) ' Subtract 1440 minutes for each full day
minz = mins Mod 60
' Set proper 'minutes' string
If minz = 1 Then mintime = "1 minute" Else mintime = minz & " minutes"
' Combine the 3 parts to build complete string
elapsed = daytime & hourtime & mintime
End Function
No comments have been posted about This function will return a string: listing Days, Hours, and Minutes, when given a total number of . Why not be the first to post a comment about This function will return a string: listing Days, Hours, and Minutes, when given a total number of .