Private Sub Form_Load()
With Wsk(0)
.Protocol = sckTCPProtocol
.LocalPort = 8877
.Listen
End With
End Sub
Private Sub Wsk_ConnectionRequest(Index As Integer, ByVal requestID As Long)
Dim lCount As Long
Dim StrLog As String
lCount = Wsk.UBound + 1
Load Wsk(lCount)
With Wsk(lCount)
.Accept requestID
End With
End Sub
Private Sub Wsk_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim StrValue As String
With Wsk(Index)
.GetData StrValue
Debug.Print StrValue
.SendData GetResult(StrValue)
End With
End Sub
Function GetResult(pStr As String) As Byte()
Dim i As Long
Dim StrTmp() As String
Dim lValue As Long
Dim hV As Long
Dim bByte()
Dim StrResult As String
Dim bResult() As Byte
bByte = Array(67, 72, 75, 80, 83, 0)
StrTmp = Split(pStr, Chr(0))
ReDim bResult(5)
For i = 1 To Len(StrTmp(0))
lValue = lValue + Asc(Mid(StrTmp(0), i, 1))
Next
hV = "&H" & Right(Hex(lValue + 1), 2)
For i = 0 To UBound(bByte)
bResult(i) = (bByte(i) Xor hV)
Next