今度は、HHMMDDを取得します。
引数も同様に、1以上の場合は”HH:MM:SS”を、0の場合は”HHMMSS”です。


Private Function GET_HHMMSS(ByVal STR_Flag)
  Dim STR_Temp
  Dim STR_HHMMSS

  If Not IsNumeric(STR_Flag) Then Exit Function End If

  STR_Temp = Hour(Now())
  If Len(Hour(Now())) = 1 Then STR_Temp = "0" & Hour(Now())
  If STR_Flag >= 1 Then STR_Temp = STR_Temp & ":" End If
  STR_HHMMSS = STR_Temp

  STR_Temp = Minute(Now())
  If Len(Minute(Now())) = 1 Then STR_Temp = "0" & Minute(Now())
  If STR_Flag >= 1 Then STR_Temp = STR_Temp & ":" End If
  STR_HHMMSS = STR_HHMMSS & STR_Temp

  STR_Temp = Second(Now())
  If Len(Second(Now())) = 1 Then STR_Temp = "0" & Second(Now())
  STR_HHMMSS = STR_HHMMSS & STR_Temp

  GET_HHMMSS = STR_HHMMSS
End Function

Scriptのダウンロードは こちら です。

Leave a Reply