VB 怎样在TEXTBOX中每输入一个数字MSGBOX弹出显示其ASCII码

来源:百度知道 编辑:UC知道 时间:2024/06/14 15:10:51

Private Sub Text1_KeyPress(KeyAscii As Integer)
MsgBox "ASCII码为" & Asc(Text1.Text)
Text1.Text = ""
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If Chr(KeyCode) >= 0 And Chr(KeyCode) <= 9 Then MsgBox KeyCode
End Sub

或者:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If "0" <= Chr(KeyAscii) And Chr(KeyAscii) <= "9" Then
MsgBox Hex(KeyAscii)
End If
End Sub