Monday, October 4, 2010

Visual Basic Date and Time Function : Time , Time$

Purpose : The Time function returns the current system time as a date data type . the Time$ function returns your computer's systems time as a string.

Syntax :
Time
Time$

Return values of the Time and Time$ functions
Time : Description
Hour(hh) : A number between 00 and 23 inclusive
Minute (mm) : A number between 00 and 59 inclusive
Second (ss) : A number between between 00 and 59 inclusive

Option Explicit
Private Sub cmdClose_Click()
If tmrStopWatch.Enabled = False Then
tmrStopWatch.Enabled = True
cmdClose.Caption = "Close"
Else
tmrStopWatch.Enabled = False
cmdClose.Caption = "Start"
End If
End Sub

Private Sub Form_Load()
tmrStopWatch.Interval = 500
End Sub

Private Sub tmrStopWatch_Timer()
tmrStopWatch.Interval = 500
txtNow(0).Text = Time
txtNow(1).Text = Time$
txtNow(2).Text = Format(Time, "hh:mm")
End Sub

No comments:

Post a Comment