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

    Simple timer problem

    I want to start a timer when a command button is pressed on one form and
    i want to stop timing when a command button is pressed on another form. How can
    this be done. How does the other form know there is a timer running?


  2. #2
    Guest

    Re: Simple timer problem

    On First Form

    private Sub Command1_Click()
    'Turn timer on
    Timer1.Enabled = true
    End Sub





    On Second Form

    private Sub Command2_Click()
    If Form1.Timer1.Enabled = true then
    'Timer is running
    Form1.Timer1.Enabled = false
    else
    'Timer is not running
    End If
    End Sub




    Alternate for Second Form
    (Turn it off without checking it)


    private Sub Command3_Click()
    'Ensure timer is turned off
    Form1.Timer1.Enabled = false
    End Sub





  3. #3
    Guest

    Re: Simple timer problem

    Thanks. That works, but i heard it was bad programming practice to do it that way although i can't see a way round it!


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