|
-
Oct 17th, 2001, 09:19 AM
#1
Thread Starter
PowerPoster
Minutes into Hour
Is there any predefined function which I can use to convert minutes into hours?
75 minutes should be 01:15
20 minutes should be 00:20
-
Oct 17th, 2001, 09:27 AM
#2
Here you go:
VB Code:
Public Function GetFormatTime(p_lngMinutes As Long) As String
Dim strHour As String
Dim strMinutes As String
strHour = Format(p_lngMinutes / 60, "00")
strMinutes = Format(p_lngMinutes Mod 60, "00")
GetFormatTime = strHour & ":" & strMinutes
End Function
Then call it like this:
MsgBox GetFormatTime(75)
-
Oct 17th, 2001, 09:31 AM
#3
Lively Member
Try this
Code:
Private Sub Command1_Click()
Dim d As Date
d = Date
d = DateAdd("n", 75, d)
Debug.Print Format(d, "hh:mm")
End Sub
-
Oct 17th, 2001, 09:39 AM
#4
Thread Starter
PowerPoster
Serge, your code has some problems. Try converting 20.
-
Oct 17th, 2001, 09:48 AM
#5
Thread Starter
PowerPoster
sjwesley
Your code returns the same output always
-
Oct 17th, 2001, 09:55 AM
#6
Here's a function:
VB Code:
Function GetHoursMinutes(ByVal lMinutes As Long) As String
Dim lHours As Long
lHours = lMinutes \ 60
lMinutes = lMinutes Mod 60
GetHoursMinutes = Format(lHours, "0#") & ":" & Format(lMinutes, "0#")
End Function
-
Oct 17th, 2001, 10:04 AM
#7
Oops, typo.....I had Format(strHour & ":" & strMinutes). I cant use format because Format recognizes a valid date/time.
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
|