I hate being a n00b. I’m such a VB novice that I have no idea what I’m doing and am simply reading the help file, trying something, reading some more, etc…
BE GENTLE…
I have a timer that is being activated by a button. When I click the button it starts. When I click it again, it stops. It then takes the elapsed time and saves the value (to be put in a database later, but baby steps). It keeps a running total for every time I start/stop the timer. That part works. I’m sure it’s not the best way, but I thought it was cool I was able to get that to work. Anyways….
I added a check box so that when the checkbox is checked, it saves the elapsed time value in a different field. That works too. Woo Hoo! (regular work hours vs. OT hours – it’s for keeping track of my time)
Now, I want to be able to make sure that if I try and click on the checkbox (whether it’s on or off) while the timer is “on” then it will give me an error message, NOT change the checkbox, and NOT interrupt the timer.
So far I’ve been checking to see if the timer is “off” by setting the value of the field to a bizarre date and time, 10/10/1000. Whenever I “stop” the timer, I reset all the values to 10/10/1000.
I have figured out how to make sure the timer is “off” by simply checking to see if the value of my “time” field is 10/10/1000. But, I’m having trouble figuring out how to see if the checkbox has changed without upsetting the process. I’ve seen some examples of how to determine the state of the checkbox, but it’s a little over my head. I’ve been trying to check to see if the checkbox is “on” and the value is NOT 10/10/1000 (that means the timer is on) then keep the checked value on and show a pop-up window. Example;
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = False And BeginTime <> #10/10/1000# Then
CheckBoxChecked()
End If
If CheckBox1.Checked = True And BeginTime <> #10/10/1000# Then
CheckBoxUnchecked()
End If
If BeginTime = #10/10/1000# Then
SetEverythingToBlank()
End If
End Sub
Private Sub CheckBoxUnchecked()
CheckBox1.Checked = False
MsgBox("The Timer Has Already Started")
End Sub
Private Sub CheckBoxChecked()
CheckBox1.Checked = True
MsgBox("The Timer Has Already Started")
End Sub
It does NOT like me trying to set the value back to the value it was when I clicked on the checkbox. I get a “System.StackOverflowException” when it hits the “checkbox1.checked = “ step in either the CheckBoxUnchecked or the CheckBoxChecked subs.
Does someone have a way of doing this that I might be able to understand? I appreciate any direction or advice anyone has.
BE GENTLE…
I have a timer that is being activated by a button. When I click the button it starts. When I click it again, it stops. It then takes the elapsed time and saves the value (to be put in a database later, but baby steps). It keeps a running total for every time I start/stop the timer. That part works. I’m sure it’s not the best way, but I thought it was cool I was able to get that to work. Anyways….
I added a check box so that when the checkbox is checked, it saves the elapsed time value in a different field. That works too. Woo Hoo! (regular work hours vs. OT hours – it’s for keeping track of my time)
Now, I want to be able to make sure that if I try and click on the checkbox (whether it’s on or off) while the timer is “on” then it will give me an error message, NOT change the checkbox, and NOT interrupt the timer.
So far I’ve been checking to see if the timer is “off” by setting the value of the field to a bizarre date and time, 10/10/1000. Whenever I “stop” the timer, I reset all the values to 10/10/1000.
I have figured out how to make sure the timer is “off” by simply checking to see if the value of my “time” field is 10/10/1000. But, I’m having trouble figuring out how to see if the checkbox has changed without upsetting the process. I’ve seen some examples of how to determine the state of the checkbox, but it’s a little over my head. I’ve been trying to check to see if the checkbox is “on” and the value is NOT 10/10/1000 (that means the timer is on) then keep the checked value on and show a pop-up window. Example;
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = False And BeginTime <> #10/10/1000# Then
CheckBoxChecked()
End If
If CheckBox1.Checked = True And BeginTime <> #10/10/1000# Then
CheckBoxUnchecked()
End If
If BeginTime = #10/10/1000# Then
SetEverythingToBlank()
End If
End Sub
Private Sub CheckBoxUnchecked()
CheckBox1.Checked = False
MsgBox("The Timer Has Already Started")
End Sub
Private Sub CheckBoxChecked()
CheckBox1.Checked = True
MsgBox("The Timer Has Already Started")
End Sub
It does NOT like me trying to set the value back to the value it was when I clicked on the checkbox. I get a “System.StackOverflowException” when it hits the “checkbox1.checked = “ step in either the CheckBoxUnchecked or the CheckBoxChecked subs.
Does someone have a way of doing this that I might be able to understand? I appreciate any direction or advice anyone has.