VB 求编写一个小小小代码

来源:百度知道 编辑:UC知道 时间:2024/09/24 21:59:26
就是在TEXT中,如果按了“回格”键就会提示警告的代码
因为我不知道“回格”键的 ASC码

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim R
If KeyAscii = 8 Then
R = MsgBox("你按下了退格键!确认删除请单击“是”,不删除请单击“否”", vbYesNo, "警告")
If R = vbNo Then KeyAscii = 0
End If
End Sub

查一下吧
msg "警告",48,提示

空格Ascii码.8

Private Sub text1_keypress(keyascii As Integer)
If keyascii = 8 Then
MsgBox "按下了退格键", vbOKOnly, "警告"
End If
End Sub

'---------以下是显示按键的Ascii码和KeyCode码的代码,再有不知道的可以用这个程序查
Dim k As Integer

Private Sub Form_Activate()
Print "KeyCode "; " KeyAscii"; " KeyCode "; " KeyAscii"
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Print Chr(KeyCode); "--"; KeyCode; "--"; Hex(KeyCode); "H ";
k = k + 1
If k Mod 4 = 0 Then Print
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer) <