Siebel VB Language Reference > VB Language Reference >

Time Statement

This standard VB statement sets the computer's time.


Time[$] = expression



An expression that evaluates to a valid time


Not applicable


When Time (with the dollar sign, $) is used, expression must evaluate to a string of one of the following forms:


Sets the time to hh hours 0 minutes and 0 seconds.


Sets the time to hh hours mm minutes and 0 seconds.


Sets the time to hh hours mm minutes and ss seconds.

Time uses a 24-hour clock. Thus, 6:00 P.M. must be entered as 18:00:00.

If the dollar sign ($) is omitted, expression can be a string containing a valid date, or a variant of vartype 7 (date) or 8 (string).

If expression is not already a variant of vartype 7 (date), Time attempts to convert it to a valid time. It recognizes time separator characters defined in the International section of the Windows Control Panel. Time (without the $) accepts both 12- and 24-hour clocks.


This example changes the time on the computer's clock.

Sub Button_Click
   Dim newtime As String
   Dim answer As String
   On Error Resume Next
   newtime = "5:30"
   answer = PM
   If answer = "PM" or answer = "pm" then
      newtime = newtime &"PM"
   End If
   Time = newtime
   If Err <> 0 then
      Err = 0
      Goto i
      End If
End Sub

See Also

Date Function
Date Statement
Time Function
TimeSerial Function
TimeValue Function

Siebel VB Language Reference