Langage :
VB6
,
VBA
Date ajout :
20/01/2009
Posté par
PCPT
[
Liste]
DateMAJ :
20/01/2009
' à placer dans un module
Private 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 Enum ePrecisionConstants
[Precision Second]
[Precision TenthSecond]
[Precision HundredthSecond]
[Precision ThousandthSecond]
End Enum
Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Public Function GetPreciseTime(ByVal ePrecision As ePrecisionConstants) As String
Dim SysTime As SYSTEMTIME
Call GetSystemTime(SysTime)
With SysTime
GetPreciseTime = Format$(.wHour & ":" & .wMinute & ":" & .wSecond, "HH:NN:SS")
Select Case ePrecision
Case [Precision TenthSecond]: GetPreciseTime = GetPreciseTime & ":" & .wMilliseconds \ 100
Case [Precision HundredthSecond]: GetPreciseTime = GetPreciseTime & ":" & .wMilliseconds \ 10
Case [Precision ThousandthSecond]: GetPreciseTime = GetPreciseTime & ":" & .wMilliseconds
End Select
End With
End Function
Remarque :
la fonction est à appeler dans un évènement récurrent (timer vb6, dérivé de timer pour VBA)
remplacer le signe "\" par "/" pour obtenir un nombre à virgule