如下在vb.net中,if asc(e.keychar)=13有错误?该怎么解决呢?

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
打开App,查看更多内容
随时随地看视频慕课网APP