|
-
Aug 29th, 2006, 12:22 AM
#1
Thread Starter
New Member
[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!
-
Aug 29th, 2006, 12:37 AM
#2
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.
-
Aug 30th, 2006, 06:48 PM
#3
Thread Starter
New Member
Re: [2005] Making A Timer
so how do I set up one of these stopwatches?
-
Aug 30th, 2006, 06:58 PM
#4
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
-
Aug 30th, 2006, 08:29 PM
#5
Junior Member
Re: [2005] Making A Timer
nooob question: and, what is an instance ?
-
Aug 30th, 2006, 09:01 PM
#6
Re: [2005] Making A Timer
 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:
Dim myStopwatch1 As Stopwatch 'This declares a variable but does not create an instance, so the variable is Nothing.
Dim myStopwatch2 As New Stopwatch 'This declares a variable and does create an instance, so the variable refers to a Stopwatch object.
Dim myStopwatch3 As Stopwatch = New Stopwatch 'This is equiavlent to the above.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|