BleepyEvans
Active member
- Joined
- May 2, 2011
- Messages
- 41
- Programming Experience
- 1-3
Hey,
Im wondering how can I subtract a value from the value in the previous cell or cell above. Please read everything as its much harder than I just made out
-
I have created a stopwatch, and previous to using a datagridview, ive been using labels with this code:
It basically subjects the time captured on the previous button click and subtracts it from the current time. This will create the Lap time. With a datagrid this method is now not possible.
-
With help from you guys on here, Ive made a data grid which adds a new row on a button click, on the same button click it shows the lap number, the Split time, and hopefully in the end, the Lap Time.
This is my semi working code:
Label 3 is my lap count which you can just ignore.
The problem with this code is that its basically just subtracting the time now and the time now, which is 0:0.0.
-
This is where I was thinking about just simply subtracting the previous cell from the current time, to get my new lap time, but you cant subtract strings.
-
If anyone has any other ideas then please post them, even if your not sure if it will work as im out of ideas.
Thanks
Im wondering how can I subtract a value from the value in the previous cell or cell above. Please read everything as its much harder than I just made out
-
I have created a stopwatch, and previous to using a datagridview, ive been using labels with this code:
VB.NET:
If LapTimeLabel1.Text = "0:0.000" Then
LapTimeLabel1.Text = StopwatchLabel.Text
lapTime = DateTime.Now()
ElseIf LapTimeLabel2.Text = "0:0.000" Then
Dim span As TimeSpan = DateTime.Now.Subtract(lapTime)
LapTimeLabel2.Text = span.Minutes.ToString & ":" & span.Seconds.ToString & "." & span.Milliseconds
lapTime = DateTime.Now()
.......
It basically subjects the time captured on the previous button click and subtracts it from the current time. This will create the Lap time. With a datagrid this method is now not possible.
-
With help from you guys on here, Ive made a data grid which adds a new row on a button click, on the same button click it shows the lap number, the Split time, and hopefully in the end, the Lap Time.
This is my semi working code:
VB.NET:
Private Sub LapButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LapButton.Click
Dim lapTime As String
Dim PreviouslapTime As DateTime
i += 1
DataGridView1.Rows.Add(i, StopwatchLabel.Text, lapTime)
PreviousLapTime = DateTime.Now()
Dim span As TimeSpan = DateTime.Now.Subtract(PreviouslapTime)
lapTime = span.Minutes.ToString & ":" & span.Seconds.ToString & "." & span.Milliseconds
Label3.Text = Label3.Text + Val(1)
End Sub
The problem with this code is that its basically just subtracting the time now and the time now, which is 0:0.0.
-
This is where I was thinking about just simply subtracting the previous cell from the current time, to get my new lap time, but you cant subtract strings.
-
If anyone has any other ideas then please post them, even if your not sure if it will work as im out of ideas.
Thanks