Public Function RecvAscii(dataBuf As String, ByVal maxLength As Integer) As Integer
Dim count As Long
Dim c As String * 12288
Dim length As Integer
dataBuf = ""
While length < maxLength
DoEvents
count = recv(socketId, c, 12288, 0)
If count < 1 Then
RecvAscii = RECV_ERROR
dataBuf = Chr$(0)
Exit Function
End If
If c = Chr$(10) Then
dataBuf = dataBuf + Chr$(0)
RecvAscii = NO_ERROR
Exit Function
End If
length = length + count
dataBuf = dataBuf + c
Wend
RecvAscii = RECV_ERROR
End Function
I want to get the data from using above function so that once I get it then I have an opportunity to trim it to get only what I need because not all the data is required here:Private Sub CmdCread_Click()
Dim lngstatus As Long
Dim strData As String
Dim strFindata As String
Dim strDataAudit As String
' Read maximum bytes from TCP/IP Port.
lngstatus = RecvAscii(strData, 40000)
'After receiving all the data I want to trim so that I remain with the required data
strFindata = Mid(strData, 8)
strDataAudit = Chr(91) & (Left(strFindata, Len(strFindata) - 6278)) & Chr(34) & "}" & Chr(93)
Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>
Our community of experts have been thoroughly vetted for their expertise and industry experience.