Private Sub TextBox2_KeyPress(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.KeyPress If Asc(e.keychar) = 13 Then If Not IsNumeric(TextBox2.Text) Then TextBox2.Text = "" TextBox2.Focus() End If End If End Sub
茅侃侃
浏览 280回答 1
1回答
蝴蝶不菲
把ByVal e as System.EventArgs改为ByVal e As System.Windows.Forms.KeyPressEventArgs即可Private Sub TextBox2_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress If Asc(e.KeyChar) = 13 Then If Not IsNumeric(TextBox2.Text) Then TextBox2.Text = "" TextBox2.Focus() End If End IfEnd Sub