Contents

# TimeValue Function

Calculates a serial time value from the specified hour, minute, and second - parameters passed as strings - that represents the time in a single numeric value. This value can be used to calculate the difference between times.

## الصياغة:

    TimeValue (Text As String)

## Return value:

التاريخ

## المعاملات:

Text: Any string expression that contains the time that you want to calculate in the format "HH:MM:SS".

Use the TimeValue function to convert any time into a single value, so that you can calculate time differences.

This TimeValue function returns the type Variant with VarType 7 (Date), and stores this value internally as a double-precision number between 0 and 0.9999999999.

As opposed to the DateSerial or the DateValue function, where serial date values result in days relative to a fixed date, you can calculate with the values that are returned by the TimeValue function, but you cannot evaluate them.

In the TimeSerial function, you can pass individual parameters (hour, minute, second) as separate numeric expressions. For the TimeValue function, however, you can pass a string as a parameter containing the time.

### Error codes:

5 Invalid procedure call

13 Data type mismatch

## مثال:

    Sub ExampleTimerValue
    Dim daDT As Date
    Dim a1, b1, c1, a2, b2, c2 As String
        a1 = "start time"
        b1 = "end time"
        c1 = "total time"
        a2 = "8:34"
        b2 = "18:12"
        daDT = TimeValue(b2) - TimeValue(a2)
        c2 = a1 & ": " & a2 & chr(13)
        c2 = c2 & b1 & ": " & b2 & chr(13)
        c2 = c2 & c1 & ": " & trim(Str(Hour(daDT))) & ":" & trim(Str(Minute(daDT))) & ":" & trim(Str(Second(daDT)))
        MsgBox c2
    End Sub

Please support us!