Texbox dont update, why?

Imports System.Net
Imports System.Net.Sockets

Public Class Form1

#Region "Var"
    Const port As Int32 = 10000
    Private clients As New Hashtable()
    Private Server As TcpListener
    Private ipserv As IPAddress = IPAddress.Parse("192.168.1.3")
#End Region

    Friend Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        

    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Server = New TcpListener(ipserv, port)
        Try
            Server.Start()
            Do
                Dim user As New info(Server.AcceptTcpClient)
            Loop Until True
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
End Class

Public Class info
#Region "var"

    'Info sobre o cliente
    Dim user As TcpClient 'defenicao do cliente
    Dim clienteIP As String 'Ip do Cliente
    Dim data() As Byte 'para receber os dados
    Public Shared AllC As New Hashtable '"Base de Dados"

#End Region
 

    Public Sub New(ByVal cliente As TcpClient)
        Try
            user = cliente
            clienteIP = cliente.Client.RemoteEndPoint.ToString 'Traduz o Ip do Cliente
            AllC.Add(clienteIP, Me) ' Adiciona o Cliente a "Base de Dados"
            ReDim data(user.ReceiveBufferSize) ' Redimensiona o Array para receber os dados
            user.GetStream.BeginRead(data, 0, CInt(user.ReceiveBufferSize), AddressOf rsms, Nothing) ' Recebe os dados do cliente numa nova Thread
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
    Public Sub rsms(ByVal a As IAsyncResult)
        Dim tdados As Integer

        Try
            SyncLock user.GetStream
                tdados = user.GetStream.EndRead(a)
            End SyncLock
            If tdados < 1 Then
                UpdateStatus("O Cliente com o IP " & clienteIP & " deixou o Chat")
                Exit Sub
            Else
                Dim smsr As String = System.Text.Encoding.ASCII.GetString(data, 0, tdados)
                UpdateStatus(smsr)
            End If

            SyncLock user.GetStream
                user.GetStream.BeginRead(data, 0, CInt(user.ReceiveBufferSize), AddressOf rsms, Nothing)
            End SyncLock
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub UpdateStatus(ByVal statusMessage As String)
        Form1.TextBox1.Text = (statusMessage)
    End Sub

End Class

I have this code, and when execute, the textbox1 dont show the incoming data from client, why i am new in this sry if my question in a stupid question, and sry about my English

 



Answer this question

Texbox dont update, why?

  • Texbox dont update, why?