ミリ秒を含む現在時間取得

 


Option Explicit
'機能 : 現在時間(ミリ秒含む)の取得
Public Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

Public Declare Sub GetLocalTime Lib "kernel32" _
(lpSystemTime As SYSTEMTIME)

'*******************************************************************************
'オブジェクト名 : nowtime
'機能 : 現在時間(ミリ秒含む)の取得
'引数 :
'戻り値 : 正常時 現在時間
' : 異常時 NULL
'変更日時 担当者 変更内容
'2001/02/02 新規作成
'*******************************************************************************
Public Function nowtime()
Dim t As SYSTEMTIME

On Error GoTo Err_nowtime
        GetLocalTime t
        nowtime = Format$(t.wHour, "00") & ":" & _
        Format$(t.wMinute, "00") & ":" & _
        Format$(t.wSecond, "00") & "." & _
        Format$(t.wMilliseconds, "000")
Exit_nowtime:
        Exit Function

Err_nowtime:
        MsgBox Err.Description & " : " & _
        Err.Number & " : " & _
        Err.Source & " on nowtime"
        nowtime = Null
        Exit Function

End Function




トップページに戻る

Tips一覧に戻る