编码和选择案例

时间:2013-05-29 16:52:56

标签: vb.net

当我点击一个按钮时,我的服务器向客户端发送请求,然后,客户端应该将请求传递给选择案例以确定要做什么。

但是,它不起作用。假设服务器要求“i”,客户端将收到“i”但完全避免我的选择案例。

我该如何解决这个问题?

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

1 个答案:

答案 0 :(得分:1)

我打赌你在这个字符串中有一个隐藏的字符。您应该使用Mid()函数来选择正确的子字符串。