7,765
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private Sub Command1_Click()
Dim number As Integer
Dim outbyte(0) As Byte
number = Val(Text1.Text)
outbyte(0) = CByte(number)
MSComm1.OutBufferCount = 0
MSComm1.Output = outbyte
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 3
MSComm1.Settings = "9600,N,8,1"
MSComm1.EOFEnable = True
MSComm1.RThreshold = 1
MSComm1.InputLen = 0
MSComm1.PortOpen = True
MSComm1.InBufferCount = 0
End Sub
Private Sub MSComm1_OnComm()
Dim indata As Variant
Dim arr(0) As Byte
Select Case MSComm1.CommEvent
Case commEvReceive
indata = MSComm1.Input
arr(0) = AscB(indata)
Text1.Text = arr(0)
MSComm1.InBufferCount = 0
End Select
End Sub