📄 form6.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form6
Caption = "串口二进制数据传输"
ClientHeight = 4125
ClientLeft = 60
ClientTop = 450
ClientWidth = 6795
LinkTopic = "Form6"
ScaleHeight = 4125
ScaleWidth = 6795
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 840
TabIndex = 2
Top = 3000
Width = 1215
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2295
Left = 3960
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 1
Top = 120
Width = 2535
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2295
Left = 360
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
Top = 135
Width = 2655
End
Begin MSCommLib.MSComm MSComm1
Left = 3000
Top = 2880
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
CommPort = 2
DTREnable = -1 'True
RThreshold = 1
InputMode = 1
End
End
Attribute VB_Name = "Form6"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim bytOut(1 To 5) As Byte
bytOut(1) = &H12
bytOut(2) = &H13
bytOut(3) = &H15
bytOut(4) = &H16
bytOut(5) = &H17
MSComm1.Output = bytOut
End Sub
Private Sub Form_Load()
MSComm1.PortOpen = True
End Sub
Private Sub MSComm1_OnComm()
Dim InByte() As Byte
Buf = ""
Select Case MSComm1.CommEvent
Case comEvReceive
InByte = MSComm1.Input
For i = LBound(InByte) To UBound(InByte)
Buf = InByte(i)
Text2.Text = Text2.Text & "0x" & Hex(Buf) & Chr(32)
Next i
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -