Siebel VB Language Reference > VB Language Reference >

Time Function

This standard VB function returns a string representing the current time.




Not applicable



An eight-character string of the format hh:mm:ss, where hh is the hour, mm is the minutes, and ss is the seconds. The hour is specified in military style and ranges from 0 to 23.


The dollar sign ($) in the function name is optional. If it is included, the return type is string. Otherwise the function returns a variant of vartype 8 (string).


This example writes data to a file if it has not been saved within the last two minutes.

Sub Button_Click
   Dim tempfile
   Dim filetime, curtime
   Dim msgtext
   Dim acctno(100) as Single
   Dim x, I
   tempfile = "c:\temp001"
   Open tempfile For Output As #1
   filetime = FileDateTime(tempfile)
   x = 1
   I = 1
   acctno(x) = 0
      curtime = Time
      acctno(x) = 44
      If acctno(x) = 99 then
         For I = 1 to x -1
            Write #1, acctno(I)
         Next I
         Exit Do
      ElseIf (Minute(filetime) + 2)< = Minute(curtime) then
         For I = I to x
            Write #1, acctno(I)
         Next I
      End If
      x = x + 1
   Close #1
   x = 1
   msgtext = "Contents of c:\temp001 is:" & 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
   Close #1
      Kill "c:\temp001"
End Sub

See Also

Date Function
Date Statement
Time Statement
Timer Function
TimeSerial Function
TimeValue Function

Siebel VB Language Reference