2012-03-21 28 views
-2

我必須使用vb 2010的網絡程序。我試圖在標籤文本中顯示ReadLine流,但它不會顯示。請幫忙。label.text不會顯示readline

Dim tcpCli As TcpClient = tcpList.AcceptTcpClient() 'claiming tcp listener to accept the tcp client 

Dim ns As NetworkStream = tcpCli.GetStream ' assign ns as network stream and assign as client to get nw stream 
Dim sr As New StreamReader(ns) 

''''''''' get data from client ''''''''''''''' 
Dim list As New List(Of String) 
Dim receivedData As String = sr.ReadLine() 

MsgBox("Operation Performed!!!", MsgBoxStyle.Information, "Accepted by client") 
Form1.lblRreadStream.Text = receivedData.ToString() '<< this is the line i'm stuck in with. 
+0

請。我非常需要.. – Nerdar 2012-03-21 20:54:04

+0

消息框顯示嗎? – flo 2012-03-21 21:10:24

+0

是的..它顯示 – Nerdar 2012-03-21 21:20:45

回答

0

根據您的要求,您可以執行下列操作之一:

Dim receivedData As String = sr.ReadLine() 
    While (sr.ReadLine() <> Nothing) 
     receivedData += sr.ReadLine() 
    End While 

    Form1.lblRreadStream.Text = receivedData 

或者你可以一次讀取整個流:

Form1.lblRreadStream.Text = sr.ReadToEnd() 

希望它可以幫助

+0

thx爲答案.. 但它仍然是一樣的。 :S – Nerdar 2012-03-21 21:20:09