How to clear numeric updown control and retained the value of the label?

  • Thread starter Thread starter lelouch_vi
  • Start date Start date
L

lelouch_vi

Guest
I have a NumericUpDown in my Form and a Label which changes the value depending on the NumericUpDown value change event. I also have a clear Button which clears the NumericUpDown and a save Button because my form is connected to a database.

What is happening is when I press the up in NumericUpDown the value of the Label decreases and vice versa. It works like what I wanted to. Now, what I'm trying to do is whenever I click the clear Button I want the last value of the Label to be retained. Let's say, the last value of the Label is 80 and I changed the value of the NumericUpDown to 20 so the value of the Label now is 60 when I press the clear I want the value of the Label to be 80 again and clear the NumericUpDown since I didn't click the save button I just cleared the NumericUpDown.

Below is my code for the NumericUpDown value changed.


Static num As Integer = 100
Static oldvalue As Integer

If numCategory.Value > oldvalue Then

num -= 1

lblpoints.Text = num.ToString

ElseIf numCategory.Value < oldvalue Then
num += 1
lblpoints.Text = num.ToString

Else

lblpoints.Text = ""

End If

oldvalue = numCategory.Value

Continue reading...
 
Back
Top