1.VB6.0中的串口程序串口串口通讯
2.如何用VB6.0通过串口从电子秤中获取数据?
VB6.0中的串口通讯
Dim Buffer As Variant
Dim Arr() As Byte
' 设定并开启连接埠
MSComm1.CommPort = 1
' 连线速度 baud、无同位检查、通信通讯echarts的源码下载资料位元 8、源码南非离中国源码停止位元 1
MSComm1.Settings = ",串口程序串口django简书源码N,8,1"
告诉控制项当使用 Input 时,读取整个暂存区
MSComm1.InputLen = 0
MSComm1.PortOpen = True
' 设定 InputMode 以读取二进制模式
MSComm1.InputMode = comInputModeBinary
' 等待直到输入缓冲区有 个字节
Do Until MSComm1.InBufferCount <
DoEvents
Loop
' 将二进制数据放入Buffer中
Buffer = MSComm1.Input
' 把数据给指定的通信通讯半导体源码泄漏数组
Arr = Buffer
MSComm1.PortOpen = False
' 通过Arr(5) 就可以得到第N个元素了
如何用VB6.0通过串口从电子秤中获取数据?
Option Explicit
Dim strss As String
Private Sub Form_Load()
MSComm1.CommPort = 1 '串口号,
MSComm1.Settings = ",源码姓名滚动html源码n,8,1 " '串口的属性
MSComm1.InputLen = 0
MSComm1.InputMode = comInputModeText
MSComm1.RThreshold = 1
MSComm1.PortOpen = True
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive
strss = strss & MSComm1.Input
If Right(strss, 2) = vbCrLf Then
Label1.Caption = strss
Open "D:\DATA.txt" For Append As #1
Print #1, Mid(strss, 1, Len(strss) - 2) '去除回车换行
Close
strss = ""
End If
End Select
End Sub
2024-11-18 16:19
2024-11-18 15:57
2024-11-18 15:56
2024-11-18 14:59
2024-11-18 14:59
2024-11-18 14:53
2024-11-18 14:30
2024-11-18 14:25