frmSerial.MSComm1.CommPort = 1 'Example of Comm 1 frmSerial.MSComm1.Settings = "9600,o,7,1" 'Example of 9600 Baud,Parity,Data,Stop
frmSerial.MSComm1.InputLen = 1 'Read one character at a time
frmSerial.MSComm1.PortOpen = True 'Open port
哪里有错误?
Ports.Add("COM5")
With Ports("COM5")
.close
.Parity=Parity.Odd
.StopBits=StopBits.One
.BaudRate = 9600
.DataBits =7
'.ReadTimeout=2000
.Open
End With
[此贴子已经被作者于2024/7/4 15:52:05编辑过]
没看出有啥问题。代码执行有什么错误?确定设备使用的是
COM5吗
Ports("COM5").Write("READ?")
'例如向COM2写入字符"abcd":
Dim TdataReceivedXYZ As String
TdataReceivedXYZ = Ports("COM5").ReadLine
Ports("COM5").InputLen = 1 '设置Input 一次从接收缓冲读取字节数为1
没有这种设置。如果是要接收一个字节内容,参考:
http://www.foxtable.com/webhelp/topics/1979.htm
Dim Val(0) As Byte
e.Port.Read(val,0,1)