Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如果不符合条件,则在文本框中保留旧值_Vb.net_Math_Textbox - Fatal编程技术网

Vb.net 如果不符合条件,则在文本框中保留旧值

Vb.net 如果不符合条件,则在文本框中保留旧值,vb.net,math,textbox,Vb.net,Math,Textbox,我有一个函数,其中一个特定值不允许超过另一个值。但是,如果是这样的话,我希望保留在文本框中的旧值,在进行更改之前就在那里。我该怎么做 Private Sub TextBox20_TextChanged(sender As Object, e As EventArgs) Handles TextBox20.TextChanged 'PREVENTS THE USER FROM APPLYING A THICKNESS GREATER THAN THE HIGHT AND LENGTH O

我有一个函数,其中一个特定值不允许超过另一个值。但是,如果是这样的话,我希望保留在文本框中的旧值,在进行更改之前就在那里。我该怎么做

Private Sub TextBox20_TextChanged(sender As Object, e As EventArgs) Handles TextBox20.TextChanged

    'PREVENTS THE USER FROM APPLYING A THICKNESS GREATER THAN THE HIGHT AND LENGTH OF THE EXTRUSION SPECIFIDE...S
    If TextBox20.Text >= ((TextBox17.Text / 2) + 1) Or TextBox20.Text >= ((TextBox18.Text / 2) + 1) Then
        MessageBox.Show("CAUTION!" & vbCrLf & vbCrLf & "The material thickness cannot exceed the" & vbCrLf & "total height or width of the extrussion " & vbCrLf & "Either reduce the material thickness or increase the total " & vbCrLf & "height and or width of the extrusion", "Important Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
    End If
    'PREVENTS THE USER FROM APPLYING A THICKNESS GREATER THAN THE HIGHT AND LENGTH OF THE EXTRUSION SPECIFIDE...E

End Sub

您可以使用验证事件并设置e.Cancel=true以防止发生文本更改-

Private Sub TextBox20_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles TextBox20.Validating
        If {your logic} Then
            'messagebox
            e.Cancel = true
            Return
        End If
    End Sub

您可以使用验证事件并设置e.Cancel=true以防止发生文本更改-

Private Sub TextBox20_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles TextBox20.Validating
        If {your logic} Then
            'messagebox
            e.Cancel = true
            Return
        End If
    End Sub