Results 1 to 6 of 6

Thread: [2005] Making A Timer

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Location
    Australia
    Posts
    10

    [2005] Making A Timer

    Hi, I am running an Internet Cafe in a small country town. We have 15 Computer 14 of them are running Windows XP and the main one running Windows Server 2003. What we want to make is a program that that has 14 buttons on it so that when somebody comes in we can click to time how long they are on a certain computer for.

    How do you make a timer? I want it so that you click start and the button text then changes to stop and then you can click stop and it show the time next to the button. Would this be very hard to do?

    Cheers!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Making A Timer

    .NET 2.0 includes the Stopwatch class that will do exactly what you want. You just create an instance and call the appropriate methods when the Button is clicked. I would also recommend that you use a CheckBox instead of a Button. If you set the Appearance property of the CheckBox to Button then it looks exactly like a regular Button control, but when you press it it stays depressed until you press it again. Depressed corresponds to checked and released corresponds to unchecked.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2006
    Location
    Australia
    Posts
    10

    Re: [2005] Making A Timer

    so how do I set up one of these stopwatches?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Making A Timer

    You create an instance and then check the documentation or use Intellisense to see what members it has. The documentation has a code example. The following page is the result of searching for "stopwatch class" on MSDN.

    http://search.msdn.microsoft.com/sea...topwatch+class
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Junior Member Danillo55's Avatar
    Join Date
    Aug 2006
    Posts
    16

    Re: [2005] Making A Timer

    nooob question: and, what is an instance ?

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Making A Timer

    Quote Originally Posted by Danillo55
    nooob question: and, what is an instance ?
    Every object is an instance of its type. In the real world Person is a type and you are an instance of that type. In VB you have to use the 'New' keyword to create an instance of a class, e.g.
    VB Code:
    1. Dim myStopwatch1 As Stopwatch 'This declares a variable but does not create an instance, so the variable is Nothing.
    2.  
    3. Dim myStopwatch2 As New Stopwatch 'This declares a variable and does create an instance, so the variable refers to a Stopwatch object.
    4.  
    5. Dim myStopwatch3 As Stopwatch = New Stopwatch 'This is equiavlent to the above.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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