1
如何将字符串转换为包含在第一个索引& H81 Byte数组,如果字节数组mybyte(0)与字符串转换为与&H81 VB6字节包含在第0指数
我需要在我的字节来检查阵列
Private Declare Sub CopyMemory _
Lib "kernel32" _
Alias "RtlMoveMemory" (Destination As Any, _
Source As Any, _
ByVal Length As Long)
Private Sub cmdCommand1_Click()
Dim str As String
Dim BT() As Byte
BT() = StrToByte(tbMsg.Text)
If BT(0) = &H81 Then
'MyCode
End If
End Sub
的如果mybyte(0)= & H81然后条件allays得到假
,目前我使用这个字符串转换为字节转换方法
Public Function StrToByte(strInput As String) As Byte()
Dim lPntr As Long
Dim bTmp() As Byte
Dim bArray() As Byte
If Len(strInput) = 0 Then Exit Function
ReDim bTmp(LenB(strInput) - 1) 'Memory length
ReDim bArray(Len(strInput) - 1) 'String length
CopyMemory bTmp(0), ByVal StrPtr(strInput), LenB(strInput)
For lPntr = 0 To UBound(bArray)
If bTmp(lPntr * 2 + 1) > 0 Then
bArray(lPntr) = Asc(Mid$(strInput, lPntr + 1, 1))
Else
bArray(lPntr) = bTmp(lPntr * 2)
End If
Next lPntr
StrToByte = bArray
End Function
谢谢@Alex K,感谢正确我的错误,我已经尝试过这种方法,并且该条件仍然是假的, –
我实际上试图发送数据到WinSock到WebSocket ,, 与我的问题相关,,,如果你有任何关于这个问题的想法,请帮助我。 。:) quastion 2 - http://stackoverflow.com/questions/37537671/send-string-from-vb6-winsock-to-websockets –
和我以前的一个问题是这样的,问题1 - http://stackoverflow.com/questions/37250260/vb6-winsock-server-connect-with-websocket,还没有回答,我没有通过那部分,现在我被困在这部分,根据第二个问题转换数据并将数据发送回websocket –