Hi i am new to this forum,big help on sockets..

xydeown

New member
Joined
Mar 28, 2008
Messages
1
Programming Experience
Beginner
Hi, i am new here..
i have a prablom i made a project (chat) with sockets its working all good,
when my friend connect and i try to send message i get crash and in the bug say this code wrong : and this line :

VB.NET:
Public Sub ServerSendData()

        Dim bytes() As Byte = ASCII.GetBytes(txtName.Text & ": " & frmClient.txtChat.Text)
        [COLOR="Red"]ServerClientSocket.Send(bytes)[/COLOR]
        With frmClient.txtChat
            .SelectionStart = .Text.Length
            .SelectedText = txtName.Text & ": " & frmClient.txTsend.Text & vbCrLf
        End With
    End Sub

the red line is not good .. any one know how to fix the code and why i get crash ?
 
It would be hard to guess what exactly the problem is. Try adding error handlers to see the exact error message which is causing crash i.e. add Try Catch blocks and check for the exception message as shown below:
Public Sub ServerSendData()

Try
Dim bytes() As Byte = ASCII.GetBytes(txtName.Text & ": " & frmClient.txtChat.Text)
ServerClientSocket.Send(bytes)
With frmClient.txtChat
.SelectionStart = .Text.Length
.SelectedText = txtName.Text & ": " & frmClient.txTsend.Text & vbCrLf
End With
Catch ex As Exception
Debug.Print(ex.Message)
End Try

End Sub

Regards,
Dave
 
Back
Top