VB串口通信,多路采集问题
下位机为单片机,上位机VB编程,4个传感器采集信号,送到单片机处理,通过AD转换,传给上位机,在串口助手上能显示4路的信号,分别为
value[0]=1.28
value[1]=1.23
value[2]=1.25
value[3]=1.27
value[0]=1.28
value[1]=1.23
value[2]=1.25
value[3]=1.27
.
.
.
怎样在VB中把这4路信号分别采集出来,并且分别赋值给U1,U2,U3,U4
[解决办法]
Dim InputStr As String
Dim U1 As String, U2 As String, U3 As String, U4 As String
InputStr = MSComm1.Input
Select Case Mid(InputStr, 1, 8)
Case "value[0]"
U1 = Mid(InputStr, 10, Len(InputStr))
Case "value[1]"
U2 = Mid(InputStr, 10, Len(InputStr))
Case "value[2]"
U3 = Mid(InputStr, 10, Len(InputStr))
Case "value[3]"
U4 = Mid(InputStr, 10, Len(InputStr))
End Select