Dim buffer2(0) As Byte Dim data as Integer MSComm2.InputMode = comInputModeBinary data=&H10 buffer2(0) = CByte(data Mod 256) MSComm2.Output=buffer2这样就可以发送16到串口了
Dim buffer2(0) As Byte Dim data as Integer MSComm2.InputMode = comInputModeBinary data=&H10 buffer2(0) = CByte(data Mod 256) MSComm2.Output=buffer2 把data定义成全局变量 然后把上面的代码放到一个函数SendData里面 隔一段时间调用 data=A Call SendData slpe
arr(0)=&H45
arr(1)=&H46
arr(2)=&H47
arr(3)=&H48
MSComm1.Output = arr
Dim data as Integer
MSComm2.InputMode = comInputModeBinary
data=&H10
buffer2(0) = CByte(data Mod 256)
MSComm2.Output=buffer2这样就可以发送16到串口了
比如:
起始位为&01
结束位为&09
Dim data as Integer
MSComm2.InputMode = comInputModeBinary
data=&H10
buffer2(0) = CByte(data Mod 256)
MSComm2.Output=buffer2
把data定义成全局变量
然后把上面的代码放到一个函数SendData里面
隔一段时间调用
data=A
Call SendData
slpe
然后把上面的代码放到一个函数SendData里面
隔一段时间调用
data=A
Call SendData
sleep 1000
data=B
Call SendData
......
dim varR as variant
dim bytAry(1) as byte
bytAry(0) = &h11
bytAry(1) = &h22varR = bytAry
MsComm1.output = varR