Click to See Complete Forum and Search --> : Time


The Matrix
February 29th, 2000, 06:12 PM
I am trying to make a program where, when you put 'start' and when you push that button, it records the time, then when you push 'stop' it records the time, and displays the time in a label, thnx

AndyK
February 29th, 2000, 07:31 PM
That was a bit confusing....Do you want to make a timer?
1) Make 2 command buttons, 1 label

Dim St as Boolean
private Sub Command1_Click()
Do Until St = true
Label1.Caption = Label1.Caption + 1
Pause 1
Loop
End Sub

private Sub Command2_Click()
St = true
End Sub

private Sub Form_Load()
Command1.Caption = "Start"
Command2.Caption = "Stop"
Label1.Caption = 0
St = false
End Sub

Sub Pause(interval)

Current = Timer
Do While Timer - Current < Val(interval)
DoEvents
Loop
End Sub



if you want to do something with TIME then just use something like

MsgBox CStr(time)

Kyle Burns
March 1st, 2000, 11:22 AM
I think this is what you want

'In General Declarations
Dim dtStart as date
Dim dtEnd as date
'-----------------------
private Sub Form_Load()
cmdStart.Enabled = true
cmdEnd.Enabled = false
lblDisplay.Caption = vbNullString
End Sub
private Sub cmdStart_Click()
dtStart = Now()
cmdStart.Enabled = false
cmdEnd.Enabled = true
End Sub
private Sub cmdEnd_Click()
dtEnd = Now()
cmdEnd.Enabled = false
cmdStart.Enabled = true
lblDisplay.Caption = DateDiff("s",dtStart, dtEnd)
End Sub