And the code in VB.net
Cheked.................
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("!V32 1" & 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(12).Text = txtonlyCounter
Catch
ListView1.Items.Item(PrinterIndex).SubItems.Add(12).Text = txtonlyCounter
End Try
Else
If Not networkStream.CanRead Then
tcpClient.Close()
Else
If Not networkStream.CanWrite Then
tcpClient.Close()
End If
End If
End If