The VBA Second Function returns the second component of a supplied time. The syntax of the function is:
A simple example of the VBA Second function is shown below:
' Extract the second component from the time "17:56:33"
Const currTime = "17:56:33"
Dim secNum As Integer
secNum = Second(currTime)
' The variable secNum is now equal to 33.
|
After running the above VBA code, the variable secNum holds the value 33, which is the second component of the supplied time "17:56:33".
If the VBA Second function is supplied with a value that cannot be interpreted as a valid time, it will return the error: