如何在vb.net中更改之前跟踪以前的值

时间:2016-05-09 07:30:56

标签: vb.net

 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: " & 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 = ""

我试图将先前的点nudX4和nudY4的值存储在两个局部变量中。但是当我取消选中我的复选框时,nudX4和nudY4的值仍然等于nudX1和nudY1的值,而不是改回以前的值。

请帮忙。

1 个答案:

答案 0 :(得分:0)

Private Sub chkLoop_CheckedChanged(sender As Object, e As EventArgs) Handles chkLoop.CheckedChanged
    If chkLoop.Checked Then
        ...
        intValue1 = nudX4.Value
        intValue2 = nudY4.Value
    ElseIf chkLoop.CheckState = CheckState.Unchecked Then
        nudX4.Value = intValue1
        nudY4.Value = intValue2
       ...