KeyPress事件
套用至
TextBox
描述
在點選按鍵時發生。
使用方式
Form_Control_KeyPress (Sender$ As String, ByRef Key$ As String)
- Sender$
- 被設定為引發事件的控制項名稱。
- Key$
- 按下的按鍵的字串。
備註
Keypress事件可用於偵測操作人員輸入的按鍵。
此事件可當成篩選條件使用。可設定Key$為其他字元變更按下的按鍵。您可設定Key$為空字串以取消keypress。
另請參閱
TextBox
範例
Function frmMain_txtSpeed_KeyPress(Sender$ As String, ByRef Key$ As String)
' 只允許輸入數字
If Instr("0123456789" Key$) < 0 Then
Key$ = ""
EndIf
Fend