📄 kb.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form KB
Caption = "键盘中断实验 苏州大学freescale MCU&DSP研发中心 2005年3月版"
ClientHeight = 2610
ClientLeft = 3015
ClientTop = 2370
ClientWidth = 9225
Icon = "KB.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2610
ScaleWidth = 9225
Begin MSCommLib.MSComm MSComm1
Left = 150
Top = 1320
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.CommandButton CmdEXIT
Caption = "退出"
BeginProperty Font
Name = "Tahoma"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 4830
TabIndex = 5
Top = 1620
Width = 1125
End
Begin VB.CommandButton CmdCLR
Caption = "清空"
BeginProperty Font
Name = "Tahoma"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3090
TabIndex = 4
Top = 1620
Width = 1125
End
Begin VB.TextBox Txtchr
Alignment = 2 'Center
BackColor = &H00C0FFFF&
BeginProperty Font
Name = "黑体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 7050
Locked = -1 'True
TabIndex = 3
Text = "446546"
Top = 690
Width = 1305
End
Begin VB.TextBox Txthex
Alignment = 2 'Center
BackColor = &H00C0FFFF&
BeginProperty Font
Name = "黑体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 2880
Locked = -1 'True
TabIndex = 2
Text = "ky"
Top = 660
Width = 1305
End
Begin VB.Label Labkbv
Caption = "对应的键值"
BeginProperty Font
Name = "Tahoma"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 4860
TabIndex = 1
Top = 690
Width = 1875
End
Begin VB.Label Labkbchr
Caption = " 按 键"
BeginProperty Font
Name = "Tahoma"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 780
TabIndex = 0
Top = 690
Width = 1845
End
End
Attribute VB_Name = "KB"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'程序描述:把接收到的数据显示在接收窗口中
'-------------------------------------------------------
Option Explicit '检查未经声明的变量
Dim RecvData() As Byte '接收数据数组
Dim x As String '存放A-F的字符
Private Sub Form_Load()
'清空有关文本框
Txthex.Text = ""
Txtchr.Text = ""
Call SCIinit(MSComm1, 1, "9600,N,8,1")
'开放串行中断
MSComm1.RThreshold = 1
End Sub
Public Sub MSComm1_OnComm() '串行接收中断
Dim i As Integer
Dim S1 As String, S2 As String
MSComm1.RThreshold = 0 '关闭串行中断
Do
DoEvents
Loop Until MSComm1.InBufferCount >= 2
RecvData = MSComm1.Input
S1 = Hex(RecvData(0))
S2 = Chr(RecvData(1))
Txthex.Text = S2
Txtchr.Text = S1
MSComm1.RThreshold = 1 '开放串行中断
End Sub
Private Sub CmdCLR_Click() '单击"清空"按钮
Txthex.Text = ""
Txtchr.Text = ""
End Sub
Private Sub CmdEXIT_Click() '单击"退出"按钮
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -