串口应用实例.docxVIP

  • 29
  • 0
  • 约1.44万字
  • 约 18页
  • 2016-12-03 发布于河南
  • 举报
串口应用实例

串口应用实例Private Sub commload()On error goto errlineCounter=0for i=0 to 16mport=imscomm1.portopen=trueif mscomm1.portopen=true thenmscomm1.portopen=falsecombo1.additem “ COM”+cstr(i),countercounter=counter+1end if next icombo1.listindex=0end suberrline:if err.number=8005 then combo1.additem “com”+cstr(i),countercounter=counter+1end if resume nextend sub此段代码是扫描串口,并把串口添加到combo1的里面。默认选择的是第一个扫描到的。调入计算机存在的串口(counter++),这个很重要。随着某些变量的变化,用counter的++来保存所有需要的变量。不管之前的变量是不是连续或者离散的。Counter只是负责把需要的全部都记下来。用时自己选择对应需要的。串口初始化Mport=1Mscomm1.setting=”9600,n,8,1”Mscomm1.inbuffersize=1024Mscomm1.outbuffersize=4096Msco

文档评论(0)

1亿VIP精品文档

相关文档