[VB.NET]TextBox判断输入后是否有按Enter

在TextBox加入KeyPress的事件,然后判断输入的符


在TextBox加入KeyPress的事件,然后判断输入的符

Private Sub TextBox2_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
        If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
            MsgBox("输入的值是" & TextBox2.Text)
        End If
End Sub