Home > Software engineering >  VB winsock control TCP client receive hexadecimal data garbled words, beg to solve ~
VB winsock control TCP client receive hexadecimal data garbled words, beg to solve ~

Time:10-08

Private Sub Winsock1_DataArrival (ByVal bytesTotal As Long)
Dim (a) As Byte
Winsock1. GetData a, vbArray Or vbByte
Text_Rec. Text=a
End Sub
This is my a receiving code, send the hexadecimal data, receiving to hexadecimal form, but I receive is garbled, don't know what's the matter, for great god help, online waiting ~
The code appears like this???????
? 漄???
????? U
This is I send the data to return the code

CodePudding user response:

 ReDim iBuf (bytesTotal - 1) 
TcpRTB. GetData iBuf
'the log every byte received
'I=0
'LNX="RTB - & gt; BYTE: "+ Right (" 0000000" + Hex (I), 8) + "-"
'For I=0 To bytesTotal - 1
'LNX=LNX + "" + Right (" 0" + Hex (iBuf (I)), 2)
'If I Mod 16=15 Then
'LogRX LNX
'LNX="RTB - & gt; BYTE: "+ Right (" 0000000" + Hex (I + 1), 8) + "-"
'End If
'Next
'I=bytesTotal - 1
'If I Mod 16 & lt;> 15 Then
'LogRX LNX
'End If

CodePudding user response:

Double byte is sent?
Under the strconv conversion

CodePudding user response:

 Private Sub Winsock1_DataArrival (ByVal bytesTotal As Long) 
Dim () As a Byte, the I, As Long As strTmp String

Winsock1. GetData a, vbArray Or vbByte
For I=0 To bytesTotal - 1
StrTmp=strTmp & amp; The IIf (I, ""," ") & amp; Right (" 00 "& amp; Hex (a (I)), 2)
Next I
Text_Rec. Text=strTmp
End Sub
  • Related