使用winsock控制元件做tcp助手,客戶端的winsock控制元件名為tcpclient。下面程式是winsock的資料接收部分,分為十六進制顯示和字符顯示。字符顯示正常,可是選十六進制時總是顯示“實時錯誤13,型別不匹配”。請高手指點
Dim strData As String
tcpclient.GetData strData
If Check1.Value = 1 Then
txtOutput.Text = txtOutput.Text & Hex(strData) & " "
Else
txtOutput.Text = txtOutput.Text & strData
End If
End Sub
uj5u.com熱心網友回復:
If Check1.Value = 1 Then
For i = 1 To Len(strData)
txtOutput.Text = txtOutput.Text & Hex(Asc(Mid(strData, i, 1))) & " "
Next i
Else
uj5u.com熱心網友回復:
Dim iBuf() As Byte
Dim lnx As String
Dim i As Long
On Error Resume Next
' 收當前流
ReDim iBuf(bytesTotal - 1)
tcpclient.GetData iBuf
' log每個收到的位元組
i = 0
lnx = "SVR-->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
debug.print lnx
lnx = "SVR-->BYTE:" + Right("0000000" + Hex(i + 1), 8) + "-"
End If
Next
i = bytesTotal - 1
If i Mod 16 <> 15 Then
debug.print lnx
End If
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/150551.html
標籤:VB基礎類
