組合框不應接受任何輸入和退格。我的代碼接受退格。組合框中的限制不應刪除combox中的文本
Private Sub ComboBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox5.KeyPress
If Asc(e.KeyChar) <> 13 And Asc(e.KeyChar) <> 8 And Not IsNumeric(e.KeyChar) Or IsNumeric(e.KeyChar) Then
e.Handled = True
End If
End Sub
只是允許「Enter」而不是限制其他所有內容? – Fejs
你的'如果'陳述是多餘的,很難理解。你真的想要允許/阻止哪些按鍵? FWIW它是你的'Asc(e.KeyChar)<> 8'檢查,允許退格。 –