Hi, I was just wondering if there was anyway to create some sort of stopwatch, that doesnt include labels signifing, milli seconds etc?

Thanks

Welcome BleepyE.

Read the forum rules. You need to show effort, and what better way than posting the code that you have tried so far?

Homework policy

Edited 5 Years Ago by __avd: n/a

private void frmCustomerDetails_Load(object sender, EventArgs e)
{

 lblTime.Text = DateTime.Now.ToLongTimeString();
            btnStopWatch.Enabled = false;
}



private void btnStopWatch_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            btnEnterRecords.Enabled = true;
            btnStopWatch.Enabled = false;
        }

Edited 5 Years Ago by __avd: Added [code] tags. Do wrap your programming code blocks within [code] ... [/code] tags

Sorry was on my phone when I created this thread.

Current code consists of adding 1 to a value of a label ever timer tick.
Pritty basic stuff.

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        timer1.start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Label1.Text = 10 Then
            Label2.Text += 1
            Label1.Text = 0
        Else
            Label1.Text += 1
        End If
    End Sub

  
End Class

Id really prefer a method of accuratly timing something, like a stopwatch, but not using labels.

Something that I would develop into a application that recorded times.

Thanks

@Santyfurtado

I do believe that code is C not VB.net

Thanks anyway

Edited 5 Years Ago by BleepyE: n/a

Surely if you don't want to use labels you could use a public variable;

Public Class Form1

	Public TimerValue as Integer
	
	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		timer1.start()
	End Sub
	
	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		'Runs every 1 miliseconds, 1000 times a second dependant on CPU lapse time
		TimerValue = TimerValue + 1
	End Sub
	
	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		timer1.stop()
		ShowSeconds()
	End Sub
	
	Public function ShowSeconds()
		label1.text = (TimerValue / 1000)
	end function
End Class

@ange_tb

Thanks, im getting there.


I found this on the web which is closer to what im after.

Public Class Form1
    Dim Time As New DateTime 'This will just create a DateTime Element

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Timer1.Enabled = True Then
            Timer1.Stop() 'Yea....Stops if it was started
        Else
            Time = DateTime.Now 'This will change 'Time' to the current time
            Timer1.Start() 'Starts the Timer.

        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim Difference As TimeSpan = DateTime.Now.Subtract(Time) 'This is really what the entire application runs off of. It will take 'Time' Witch is set to the time that the button was clicked at and subtract it from the current time
        Label1.Text = Difference.Days.ToString & ":" & Difference.Hours.ToString & ":" & Difference.Minutes.ToString & ":" & Difference.Seconds.ToString & "." & Difference.Milliseconds.ToString 'This line...Will just make it so we can read it. Days:Hours:Minutes:Seconds.Milliseconds 
    End Sub
End Class

Its quite nice

Thanks to reconrey1292

Edited 5 Years Ago by BleepyE: n/a

This question has already been answered. Start a new discussion instead.