CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Time

  1. #1
    Join Date
    Feb 2000
    Location
    garden grove, california
    Posts
    64

    Time

    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


  2. #2
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Re: Time

    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)






  3. #3
    Join Date
    Feb 2000
    Location
    Indiana
    Posts
    308

    Re: Time

    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





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured