Frederic Daniel
Frederic Daniel

Reputation: 297

Encoding and Select Case

When i click on a button, my server sends a request to the client and then, the client is supposed to pass the request into a select case to figure out what to do.

But, it doesn't work. Let's say the server were to request "i", the client would receive "i" but would completely avoid my select case.

How can i fix this?

Private Sub Timer1_Tick(ByVal sender As System.Object,
                        ByVal e As System.EventArgs) Handles Timer1.Tick
  If _TCPStream.DataAvailable Then
    Dim rcvdbytes(_TCPClient.ReceiveBufferSize) As Byte
    _TCPStream.Read(rcvdbytes, 0, CInt(_TCPClient.ReceiveBufferSize))
    Dim request As String = System.Text.Encoding.ASCII.GetString(rcvdbytes)
    Execute_Action(request)
  End If
End Sub

Private Sub Execute_Action(ByVal request As String)
  msgbox(request) 'Says the request is "i" but do nothing
  Select Case request
    Case "i"
      messagebox.show("Hello")
  End Select
End Sub

Upvotes: 0

Views: 147

Answers (1)

gleb.kudr
gleb.kudr

Reputation: 1508

I bet you have a hidden characters in this string. You should use Mid() function to select the proper substring.

Upvotes: 1

Related Questions