NetworkStream not including the last quotation?

Posted on 2009-07-09
Last Modified: 2012-05-07
I'm trying to make a simple chat client.  But it seems that the "Dim ClientData As String = Encoding.ASCII.GetString(RevievedBytes)" is returning a string without the trailing quotation.  During a step-into, ClientData was "something.  If I manually put the other quotation on the end during a step-into, it would work.  Why is this happening?  Full project available at
Private Sub Listen(ByVal Server As String, ByVal PortNum As Int16)
    Dim MyTCPListener As New TcpListener(System.Net.IPAddress.Parse(Server), PortNum)
      Dim MyTCPClient As TcpClient = MyTCPListener.AcceptTcpClient()
      Dim NetworkStream As NetworkStream = MyTCPClient.GetStream()
      Dim RevievedBytes(MyTCPClient.ReceiveBufferSize) As Byte
      NetworkStream.Read(RevievedBytes, 0, CInt(MyTCPClient.ReceiveBufferSize))
      Dim ClientData As String = Encoding.ASCII.GetString(RevievedBytes)
      'Dim data2 As String = ClientData & Chr(34)
      Dim ClientParameters() As String = ClientData.Split("~")
      Dim ResponseString As String = ""
      Status = ClientData
      Select Case ClientParameters(0)
        Case "/send"
          ResponseString = "/print~" & ClientParameters(1)
        Case "/connect"
          ResponseString = "/ok"
      End Select
      Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(ResponseString)
      NetworkStream.Write(sendBytes, 0, sendBytes.Length)
    Catch ex As Exception
    End Try
  End Sub

Open in new window

Question by:freebullets
  • 2
LVL 41

Expert Comment

ID: 24841075
add a line after your Write() method

Author Comment

ID: 24846497
The problem is visible at this line.  When stepping into, the value of it is "clientdatahere.  It should be "clientdatahere".
Dim ClientData As String = Encoding.ASCII.GetString(RevievedBytes)

Open in new window


Accepted Solution

freebullets earned 0 total points
ID: 25002067
I fixed it by using StreamReader/Writer instead.

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question