2012-03-21 92 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