i'm facing a strange problem and i need your help.
I use this code to connect and receive some information from a barcode printer.
Code:
Private Sub Socket_Connect3(ByVal PrinterIndex As Integer, ByVal PrinterIP As String, ByVal PrinterPort As String)
'Dim i, j As Integer
'Dim FindBlank As String
Dim txtonlyCounter As Integer = 0
Dim tcpClient As New System.Net.Sockets.TcpClient
tcpClient.Connect(PrinterIP, PrinterPort)
Dim networkStream As NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes As [Byte]() = System.Text.ASCIIEncoding.ASCII.GetBytes("~HS" & vbCrLf)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes1(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes1, 0, CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = ""
returndata = Encoding.ASCII.GetString(bytes1)
tcpClient.Close()
Dim txtCounterLength As Integer = Len(returndata)
'For i = 1 To txtCounterLength
'FindBlank = Mid(returndata, i, 1)
'If FindBlank = " " Then
'j = i - 1
'txtonlyCounter = Mid(returndata, 1, j)
'Exit For
'End If
'Next i
Try
ListView1.Items(PrinterIndex).SubItems(13).Text = txtonlyCounter
Catch
ListView1.Items.Item(PrinterIndex).SubItems.Add(13).Text = txtonlyCounter
End Try
Else
If Not networkStream.CanRead Then
'MsgBox("Could not write data to data stream")
tcpClient.Close()
Else
If Not networkStream.CanWrite Then
'MsgBox("Could not read data from data stream")
tcpClient.Close()
End If
End If
End If
End Sub
The point is
the returndata (the data from printer) is something like this
"030,0,0,0584,002,0,0,0,000,0,0,0 001,0,0,0,1,1,6,1,00000043,1,001 1234,0
and the txtCounterLength (the length of the returndata) is 8.193 See attachment.
Can anyone explain me why the size is so huge?????