Get Serial Time Method
The Get Serial Time method returns a time as a variant of type 7 (date and time) for a specific hour, minute, and second.
To specify a relative time for each argument, you can use a numeric expression that identifies the number of hours, minutes, or seconds before or after a specific time.
Format
TimeSerial(hour, minute, second)
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
hour |
A numeric expression that contains a value in the range of 0 through 23 that identifies an hour. |
minute |
A numeric expression that contains a value in the range of 0 through 59 that identifies a minute. |
second |
A numeric expression that contains a value in the range of 0 through 59 that identifies a second. |
Example
The following example displays the current time:
Sub Button_Click
Dim y As Variant
Dim msgtext As String
Dim nowhr As Integer
Dim nowmin As Integer
Dim nowsec As Integer
nowhr = Hour(Now)
nowmin = Minute(Now)
nowsec = Second(Now)
y = TimeSerial(nowhr,nowmin,nowsec)
msgtext = "The time is: " & y
End Sub