简单的VB串口发送程序示例

'-----发送按钮click事件子程序-----------
private sub fasong_click()
dim jihao(0) as byte ’机号
dim head_data(4) as byte ’5 byte控制字
dim end_data(0) as byte '1 byte 结束字
jihao(0) = val(text3.text)
head_data(0) = val(text4.text)
head_data(2) = &hee 'timh
head_data(3) = &hee 'timl
head_data(4) = val(combo1.text) 'inmod
end_data(0) = &hff
if combo2.text = 增加 then head_data(1) = &h99
if combo2.text = 清空 then head_data(1) = &h33
if combo2.text = 删除 then head_data(1) = &h32
ready = 0: errcount = 0
on error goto errorcom ’打开错误处理
'----------------------------------------------------------
if com1.value then mscomm1.commport = 1 'use com1
if com2.value then mscomm1.commport = 2 'use com2
mscomm1.settings = form1.combo3.text + ,m,8,2 '设定波特率和置校验和位为1
mscomm1.inputlen = 0 '
mscomm1.portopen = -1 'open the port
mscomm1.outbuffercount = 0
mscomm1.output = jihao ‘发送机号
mscomm1.portopen = false ’关闭串口
mscomm1.settings = form1.combo3.text + ,s,8,2 '设定波特率和置校验和位为空
mscomm1.outbuffercount = 0
mscomm1.portopen = true
mscomm1.output = head_data
mscomm1.output = text2.text
mscomm1.output = end_data
mscomm1.portopen = false
text1.text = 发送成功! + chr(13) & chr(10) + 发送至 + text3.text + 屏体, + 信息编号: + text4.text + chr(13) & chr(10) + chr(13) & chr(10) + text1.text
goto comend
errorcom:
text1.text = error!请重新选择com口! + chr(13) & chr(10) + chr(13) & chr(10) + text1.text
comend:
on error goto 0
end sub

屏下指纹识别技术突破,带动2018年指纹识别渗透率达60%
高压差分探头的高频耐电压曲线及维护
新能源汽车行业前景良好之下,充电桩行业为什么要开始洗牌?
工业机器人在工业生产中有哪些优势呢
崧盛股份离正式亮相创业板资本市场,只一步之遥
简单的VB串口发送程序示例
永磁电机的结构与原理
手机充电器的维修原理解析
智能语音电话机器人的作用是什么
无铅回流焊的冷却结构装置简述
随着人脸识别技术的研究与应用 市面上开始出现人脸识别门禁系统
晶科能源高效太阳能组件和集装箱储能解决方案加速实现低碳转型发展
近十年我国制造业增加值的推动作用
屏下光学指纹识别市场广阔,产品出货量不断增加
物联网的基本原理和组成及其开发平台的结构组成和应用开发前景
“为AVR生,为 AVR死”一文了解ATMEL SKT600开发板测评
程序员的职业发展道路
智能制造与工业4.0有何不同?
小米NOTE:容得下一颗“发热”的芯
全钒氧化还原液流电池