Function formatheure(gw As Date, gwformat As String) As String
formatheure = gwformat
Dim i As Integer
i = InStr(gwformat, "[HH]"): If i > 0 Then gwformat = Left(gwformat, i - 1) & CStr((Int(gw) * 24) + Hour(gw)) & Mid(gwformat, i + 4): GoTo suite
i = InStr(gwformat, "[H]"): If i > 0 Then gwformat = Left(gwformat, i - 1) & CStr((Int(gw) * 24) + Hour(gw)) & Mid(gwformat, i + 3): GoTo suite
i = InStr(gwformat, "HH"): If i > 0 Then gwformat = Left(gwformat, i - 1) & CStr(Hour(gw)) & Mid(gwformat, i + 2): GoTo suite
i = InStr(gwformat, "H"): If i > 0 Then gwformat = Left(gwformat, i - 1) & CStr(Hour(gw)) & Mid(gwformat, i + 1): GoTo suite
suite:
i = InStr(gwformat, "[MM]"): If i > 0 Then gwformat = Left(gwformat, i - 1) & CStr(((Int(gw) * 24) + Hour(gw) * 60) + Minute(gw)) & Mid(gwformat, i + 4): GoTo suite1
i = InStr(gwformat, "[M]"): If i > 0 Then gwformat = Left(gwformat, i - 1) & CStr(((Int(gw) * 24) + Hour(gw) * 60) + Minute(gw)) & Mid(gwformat, i + 3): GoTo suite1
i = InStr(gwformat, "MM"): If i > 0 Then gwformat = Left(gwformat, i - 1) & CStr(Minute(gw)) & Mid(gwformat, i + 2): GoTo suite1
i = InStr(gwformat, "M"): If i > 0 Then gwformat = Left(gwformat, i - 1) & CStr(Minute(gw)) & Mid(gwformat, i + 1): GoTo suite1
suite1:
i = InStr(gwformat, "[SS]"): If i > 0 Then gwformat = Left(gwformat, i - 1) & CStr(((((Int(gw) * 24) + Hour(gw) * 60) + Minute(gw)) * 60) + Second(gw)) & Mid(gwformat, i + 4): GoTo suite2
i = InStr(gwformat, "[S]"): If i > 0 Then gwformat = Left(gwformat, i - 1) & CStr(((((Int(gw) * 24) + Hour(gw) * 60) + Minute(gw)) * 60) + Second(gw)) & Mid(gwformat, i + 3): GoTo suite2
i = InStr(gwformat, "SS"): If i > 0 Then gwformat = Left(gwformat, i - 1) & CStr(Second(gw)) & Mid(gwformat, i + 2): GoTo suite2
i = InStr(gwformat, "S"): If i > 0 Then gwformat = Left(gwformat, i - 1) & CStr(Second(gw)) & Mid(gwformat, i + 1): GoTo suite2
suite2:
formatheure = gwformat
End Function