vb有没有函数可以判读 yd是否和ydml相同呢
Dim yd() As Byte
Dim ydml(5) As Byte
ydml(0) = &H81
ydml(1) = &H0
ydml(2) = &H6
ydml(3) = &H0
ydml(4) = &H4B
ydml(5) = &H4D
yd = MSComm1.Input '接收应答命令
有没有函数可以判读 yd是否和ydml相同呢
[解决办法]
似乎没有,6个字节,LZ还是逐个判别吧。
Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "9600,n,8,1"
MSComm1.RThreshold = 6
MSComm1.InputMode = comInputModeBinary
MSComm1.PortOpen = True
End Sub
Private Sub MSComm1_OnComm()
Dim yd() As Byte
Dim ydml(5) As Byte
ydml(0) = &H81
ydml(1) = &H0
ydml(2) = &H6
ydml(3) = &H0
ydml(4) = &H4B
ydml(5) = &H4D
Dim i As Long
Select Case MSComm1.CommEvent
Case 2
yd = MSComm1.Input '接收应答命令
For i = 0 To UBound(yd)
If yd(i) <> ydml(i) Then
Debug.Print "yd和ydml不相同"
Exit For
End If
Next
End Select
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "9600,n,8,1"
MSComm1.RThreshold = 6
MSComm1.InputMode = comInputModeBinary
MSComm1.PortOpen = True
End Sub
Private Sub MSComm1_OnComm()
Dim yd() As Byte
Dim ydml(5) As Byte
ydml(0) = &H81
ydml(1) = &H0
ydml(2) = &H6
ydml(3) = &H0
ydml(4) = &H4B
ydml(5) = &H4D
Dim i As Long
Select Case MSComm1.CommEvent
Case 2
yd = MSComm1.Input '接收应答命令
For i = 0 To UBound(yd)
If yd(i) <> ydml(i) Then
Debug.Print "yd和ydml不相同"
Exit For
Else
Debug.Print "yd和ydml相同"
End If
Next
End Select
End Sub
If StrConv(yd, vbUnicode) = StrConv(ydml, vbUnicode) Then
'......相等
Else
'......不相等
End If