VB中SendKeys与退格键backspace怎么联用?

2024-11-29 09:33:07
推荐回答(2个)
回答(1):

SendKeys "{BKSP}" 即可。

见以下例程:

Private Sub Text1_Change()
'非数字校验~~~~~~~~~~~~~~~~~~
If IsNumeric(Text1.Text) = False And Text1.Text <> "" Then
MsgBox "请输入数字!", 48, "错误提示"
SendKeys "{BKSP}" ’两个联用
End If
End Sub

回答(2):

Private Sub Text1_Change()
'非数字校验~~~~~~~~~~~~~~~~~~
If IsNumeric(Text1.Text) = False And Text1.Text <> "" Then
MsgBox "请输入数字!", 48, "错误提示"
SendKeys "{BKSP}"
End If
End Sub