求一个vb简单程序:串口接收数据,2400,奇校验,8,1 ,端口3 10
2个回答
展开全部
Sub Form1 —load ()
form1. show
′设置COM3
comm1. commport = 3
comm1. Setting = " 2400 ,o ,8 ,1" ′波特率:9600 奇校验,8位数据,1 位停止位
comm1. Inputlen = 0 ′读取接收缓冲区的所有字符
comm1. OutBufferSize = 512 ′设置发送缓冲区为512 字节
comm1. InBufferSize = 512 ′设置接收缓冲区为512 字节
comm1. SThreshold = 0 ′禁止发送事件
comm1. RThreshold = 1 ′每一个字符到接收缓冲区都触发接收事件
′打开COM3
comm1. Portopen = True
Timer1. interval = 5000
End Sub
Sub Comm1 —OnComm()′数据接受事件
Dim Inbuff as string
Dim i as integer ,n as integer ,t as integer
Select Case Comm1. CommEven
case MSCOMM—EV—RECEIVE
Inbuff = Comm1. Input
n = len ( Inbuff)
For i = 1 to n
t = Asc (Mid ( Inbuff ,i ,1) ) or &HFF
print f
Next i
End Select
End Sub
form1. show
′设置COM3
comm1. commport = 3
comm1. Setting = " 2400 ,o ,8 ,1" ′波特率:9600 奇校验,8位数据,1 位停止位
comm1. Inputlen = 0 ′读取接收缓冲区的所有字符
comm1. OutBufferSize = 512 ′设置发送缓冲区为512 字节
comm1. InBufferSize = 512 ′设置接收缓冲区为512 字节
comm1. SThreshold = 0 ′禁止发送事件
comm1. RThreshold = 1 ′每一个字符到接收缓冲区都触发接收事件
′打开COM3
comm1. Portopen = True
Timer1. interval = 5000
End Sub
Sub Comm1 —OnComm()′数据接受事件
Dim Inbuff as string
Dim i as integer ,n as integer ,t as integer
Select Case Comm1. CommEven
case MSCOMM—EV—RECEIVE
Inbuff = Comm1. Input
n = len ( Inbuff)
For i = 1 to n
t = Asc (Mid ( Inbuff ,i ,1) ) or &HFF
print f
Next i
End Select
End Sub
2012-10-12
展开全部
1 楼 程序 稍微 改改 就可以
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询