📄 form1.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4995
ClientLeft = 60
ClientTop = 450
ClientWidth = 7230
LinkTopic = "Form1"
ScaleHeight = 4995
ScaleWidth = 7230
StartUpPosition = 3 '窗口缺省
Begin MSCommLib.MSComm MSComm1
Left = 120
Top = 4320
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 495
Left = 4680
TabIndex = 5
Top = 3840
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "发送"
Height = 495
Left = 2280
TabIndex = 4
Top = 3840
Width = 1095
End
Begin VB.TextBox Text2
Height = 495
Left = 1320
TabIndex = 1
Top = 1920
Width = 4935
End
Begin VB.TextBox Text1
Height = 495
Left = 1320
TabIndex = 0
Top = 600
Width = 4935
End
Begin VB.Label Label2
Caption = "接收的数据"
Height = 495
Left = 120
TabIndex = 3
Top = 1920
Width = 1095
End
Begin VB.Label Label1
Caption = "发送的数据"
Height = 495
Left = 240
TabIndex = 2
Top = 600
Width = 975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
'...发送数据
MSComm1.OutBufferCount = 0 '...清空输出寄存器
MSComm1.Output = Text1.Text '...发送数据
End Sub
Private Sub Command2_Click()
'...退出
Unload Me
End Sub
Private Sub Form_Load()
'...初始化
MSComm1.CommPort = 1 '...使用Com1口
MSComm1.Settings = "9600,n,8,1" '...设置通讯参数
MSComm1.PortOpen = True '...打开串口
End Sub
Private Sub Mscomm1_Oncomm()
'...通讯事件发生
Select Case MSComm1.CommEvent
Case comEvReceive '...有接受事件发生
Text2.Text = MSComm1.Input '...接受显示数据
MSComm1.InBufferCount = 0 '...清空输入寄存器
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -