Private Sub Form_Load()
s = ""
n = X 'X为快捷键的ascii码常数
Text1 = ""
Text1.Locked = True
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If Asc(Chr(KeyCode)) <> n Then
s = s & Chr(KeyCode)
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = n Then 'n为你的快捷键的ascii码
KeyAscii = 0
Text1.SelText = s 's为你要添加的字符串
Text1.Locked = False
End If
End Sub
楼主这是不是你要的
Private Sub Text1_KeyPress(KeyAscii As Integer)
Text1.Text = ""
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
KeyAscii = 0
Beep
Text1.Text = "您的输入有误!"
End If
End Sub