0

ボタンをクリックすると、サーバーがクライアントにリクエストを送信し、クライアントはリクエストを選択ケースに渡して何をすべきかを判断することになっています。

しかし、うまくいきません。サーバーが「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
4

1 に答える 1