1,502
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Dim indata As String
Private Sub Form_Load()
With MSComm1
.CommPort = 1
.Settings = "38400,n,8,1"
.OutBufferCount = 0
.InBufferCount = 0
.InputMode = comInputModeBinary
.RThreshold = 1
.SThreshold = 0
.OutBufferSize = 512
.InBufferSize = 1024
.InputLen = 0
.PortOpen = True
End With
End Sub
Private Sub MSComm1_OnComm()
Dim I As Integer
Dim strbuff As String
Dim inbte() As Byte
Select Case MSComm1.CommEvent
Case 2
strbuff = MSComm1.Input
inbte() = strbuff
For I = 0 To UBound(inbte)
If Len(Hex(inbte(I))) = 1 Then
indata = indata & "0" & Hex(inbte(I))
Else
indata = indata & Hex(inbte(I))
End If
Next I
Text1.Text = indata
End Select
End Sub