vb中mscomm以二进制发送数据和将串口2.3连接怎么用vb以二进制接收 求程序
dimbytdata()asbytePrivateSubcmdSend_Click()bytData(0)=Val(Text8.Text)bytData(1)=Val(T...
dim bytdata() as byte
Private Sub cmdSend_Click()
bytData(0) = Val(Text8.Text)
bytData(1) = Val(Text1.Text)
bytData(2) = Val(Text2.Text)
bytData(3) = Val(Text3.Text)
bytData(4) = Val(Text4.Text)
bytData(5) = Val(Text5.Text)
bytData(6) = Val(Text6.Text)
bytData(7) = Val(Text7.Text)
Call SendData(bytData())
End Sub
Public Function SendData(ByRef bytData() As Byte) As Long
On Error Resume Next
MSComm1.InBufferCount = 0 '清空接收缓冲区
MSComm1.Output = bytData '发送数据
Do
DoEvents
Loop Until MSComm1.OutBufferCount = 0 '等待,直到数据发送完毕
MSComm1.OutBufferCount = 0 '清空发送缓冲区
End Function 展开
Private Sub cmdSend_Click()
bytData(0) = Val(Text8.Text)
bytData(1) = Val(Text1.Text)
bytData(2) = Val(Text2.Text)
bytData(3) = Val(Text3.Text)
bytData(4) = Val(Text4.Text)
bytData(5) = Val(Text5.Text)
bytData(6) = Val(Text6.Text)
bytData(7) = Val(Text7.Text)
Call SendData(bytData())
End Sub
Public Function SendData(ByRef bytData() As Byte) As Long
On Error Resume Next
MSComm1.InBufferCount = 0 '清空接收缓冲区
MSComm1.Output = bytData '发送数据
Do
DoEvents
Loop Until MSComm1.OutBufferCount = 0 '等待,直到数据发送完毕
MSComm1.OutBufferCount = 0 '清空发送缓冲区
End Function 展开
1个回答
2012-05-10
展开全部
接收 可以 写 OnComm 事件
推荐看书
Visual_Basic与_RS-232_串行通信控制
推荐看书
Visual_Basic与_RS-232_串行通信控制
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询