![]() |
|
[.NET] How to Make a Simple Stopwatch - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] How to Make a Simple Stopwatch (/showthread.php?tid=4616693) |
How to Make a Simple Stopwatch - CodeBinary - Jan 2, 2015 Open up visual basic and make a windows form named anything you want. The GUI: Insert 3 buttons, and a label. Name one button's text: Start Second Button: Pause Third Button: Stop Name the label: 0.00 Insert a timer make it not enabled and a interval of: 1 The Code: Double Click the start button: Turn on the timer Code Timer1.Enabled = TrueDouble click the pause button and turn off timer Code Timer1.Enabled = FalseDouble Click Stop Button and turn off timer and reset the label to 0.0 Code Timer1.Enabled = FalseDouble click the timer and make the label tick by 0.01 Code Label1.Text = Label1.Text + 0.01Final Code: Code Public Class Form1* - Minimal. - Jan 2, 2015 With every day passing by, I lose a little bit more faith in this section... * - Odus - Jan 2, 2015 You know there is a stopwatch class with various methods and properties to measure elapsed time, right? Heed my warning, continue flooding the .NET section with ridiculous (poor) tutorials like this and your rep will sink to red my friend. That's a fact, not a threat. It's happened before. * - CodeBinary - Jan 2, 2015 (Jan 2, 2015 06:36 PM)Odus Wrote: You know there is a stopwatch class with various methods and properties to measure elapsed time, right? Heed my warning, continue flooding the .NET section with ridiculous (poor) tutorials like this and your rep will sink to red my friend. That's a fact, not a threat. It's happened before. I understand that your just correcting me but your just being a jerk now... All I am doing is trying to help geeze. * - Minimal. - Jan 2, 2015 (Jan 2, 2015 06:38 PM)Multi Bills Wrote: I understand that your just correcting me but your just being a jerk now... All I am doing is trying to help geeze. Code Label1.Text = Label1.Text + 0.01Trying to help, right... * - +Haze - Jan 2, 2015 Like Odus said, there is a stop watch class for this specific purpose. Using a timer is not the most ideal. Dim sw As New Stopwatch sw.Start() Messagebox.Show(sw.Ellap...) yeah u get the idea. |