Siebel VB Language Reference > VB Language Reference >

TimeValue Function


This standard VB function returns a time value for a specified string.

Syntax

TimeValue(time)

Argument
Description

time

A string representing a valid date-time value

Returns

A date/time value for the time represented by time.

Usage

The TimeValue function returns a variant of vartype 7 (date/time) that represents a time between 0:00:00 and 23:59:59, or 12:00:00 A.M. and 11:59:59 P.M., inclusive.

Example

This example writes a variable to a disk file based on a comparison of its last saved time and the current time. Note that the variables used for the TimeValue function are dimensioned as double, so that calculations based on their values work properly.

Sub Button_Click
   Dim tempfile As String
   Dim ftime As Variant
   Dim filetime as Double
   Dim curtime as Double
   Dim minutes as Double
   Dim acctno(100) as Integer
   Dim x, I
   tempfile = "C:\TEMP001"
   Open tempfile For Output As 1
   ftime = FileDateTime(tempfile)
   filetime = TimeValue(ftime)
   minutes = TimeValue("00:02:00")
   x = 1
   I = 1
   acctno(x) = 0
   Do
      curtime = TimeValue(Time)
      acctno(x) = 46
      If acctno(x) = 99 then
         For I = I to x-1
            Write #1, acctno(I)
         Next I
         Exit Do
      ElseIf filetime + minutes< = curtime then
         For I = I to x
            Write #1, acctno(I)
         Next I
      End If
      x = x + 1
   Loop
   Close #1
   x = 1
   msgtext = "You entered:" & Chr(10)
   Open tempfile for Input as #1
   Do While Eof(1) <> -1
      Input #1, acctno(x)
      msgtext = msgtext & Chr(10) & acctno(x)
      x = x + 1
   Loop
   Close #1
      Kill "C:\TEMP001"
End Sub

See Also

DateSerial Function
DateValue Function
Hour Function
Minute Function
Now Function
Second Function
TimeSerial Function

Siebel VB Language Reference