Home > Software engineering >  Vb do TCP assistant hexadecimal conversion problem
Vb do TCP assistant hexadecimal conversion problem

Time:11-02

Using winsock control do TCP assistant, client called tcpclient winsock control, the following procedure is the data receiving part of the winsock, divided into hexadecimal display and character, character display is normal, but choose a hexadecimal always show "real-time error 13, type mismatch", expert advice please
Both Dim strData
 As String 
Tcpclient. GetData strData
If Check1. Value=https://bbs.csdn.net/topics/1 Then
TxtOutput. Text=txtOutput. Text & amp; Hex (strData) & amp; "
"The Else
TxtOutput. Text=txtOutput. Text & amp; StrData

End the If
End Sub

CodePudding user response:

 If Check1. Value=https://bbs.csdn.net/topics/1 Then 
For I=1 To Len (strData)
TxtOutput. Text=txtOutput. Text & amp; Hex (Asc (Mid (strData, I, 1))) & amp; "
"Next I
The Else

CodePudding user response:

 Dim iBuf () As Byte 
Dim LNX As String
Dim As Long I
On the Error Resume Next
'charge current flow
ReDim iBuf (bytesTotal - 1)
Tcpclient. GetData iBuf
'the log every byte received
I=0
LNX="SVR - & 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
The debug. Print LNX
LNX="SVR - & gt; BYTE: "+ Right (" 0000000" + Hex (I + 1), 8) + "-"
End the If
Next
I=bytesTotal - 1
If I Mod 16 & lt;> 15 Then
The debug. Print LNX
End the If
  • Related