title: how to keep track of previous value before changing it in vb.net
body: <pre><code> Private Sub chkLoop_CheckedChanged(sender As Object, e As EventArgs) Handles chkLoop.CheckedChanged
      intValue1 = nudX4.Value
      intValue2 = nudY4.Value
      Dim g As TrigLib.TrigLib = New TrigLib.TrigLib
      ' Make the shape closed by making the last point the same as the first point. 
      If chkLoop.Checked Then
          nudX4.Value = nudX1.Value
          nudY4.Value = nudY1.Value
  
          lblArea.Text = "Area: " &amp; CInt(g.AreaTriangle(New Point(nudX1.Value, nudY1.Value), New Point(nudX2.Value, nudY2.Value), New Point(nudX3.Value, nudY3.Value)))
      ElseIf chkLoop.CheckState = CheckState.Unchecked Then
          nudX4.Value = intValue1
          nudY4.Value = intValue2
          lblArea.Text = ""
  </code></pre>
  
  <p>I was trying to store my previous values of point nudX4 and nudY4 in two local variable. But when i uncheck my checkbox the values of nudX4 and nudY4 remain equal to values of nudX1 and nudY1 instead of changing back to previous values.</p>
  
  <p>Please help.</p>