VBA
Rem
Rem 関数呼び出し例
Rem
Private Sub FncCall()
'使用例1:時間
Debug.Print GetTime()
'使用例2:日付+時間
Debug.Print Format(Date, "yyyy/mm/dd") & " " & GetTime()
End Sub
Rem
Rem 時分秒ミリ秒
Rem
Public Function GetTime() As String
Dim timeHmsS: timeHmsS = Timer
Dim timeHms: timeHms = Int(timeHmsS)
Dim timeS: timeS = timeHmsS - timeHms
Dim hour: hour = Int(timeHms / (60 * 60))
Dim minute: minute = Int((timeHms - (hour * 60 * 60)) / 60)
Dim second: second = timeHms - (hour * 60 * 60 + minute * 60)
Dim millisecond: millisecond = Left(Right(CStr(timeS), Len(timeS) - 1), 4)
GetTime = Format(hour, "00") & ":" & Format(minute, "00") & ":" & Format(second, "00") & Format(millisecond, ".000")
End Function