Am codul urmator de la aplicatia de aici
http://www.devarticles.com/c/a/Visual-Basic/Two-Person-Chat-With-The-Winsock-Control-And-Visual-Basic/1/Option Explicit
Private Sub AddText(ByVal text As String, ByRef Box As TextBox)
'Take the text box passed as a reference and add the "text" variable to it
Box.text = Box.text & text & vbCrLf
Box.SelStart = Len(Box.text)
End Sub
Private Sub cmdClose_Click()
Disable the outgoing buttons and tell the user that the connection has been closed
wsChat.Close
cmdClose.Enabled = False
cmdSend.Enabled = False
txtName.Enabled = True
cmdListen.Enabled = True
cmdConnect.Enabled = True
txtIn.text = "----- Connection Closed -----" & vbCrLf
End Sub
Private Sub cmdConnect_Click()
'Before we can connect, we should check to see 'if there is an IP and name for the user.
If txtIP.text = "" Or txtName.text = "" Then
MsgBox "You must enter both an IP and alias first!", vbCritical, "Error!"
txtName.SetFocus
Exit Sub
End If
On Error Resume Next
'Connecting the IP that is placed in the txtIP.text value.
wsChat.Close
wsChat.Connect txtIP.text, 23
cmdClose.Enabled = True
cmdListen.Enabled = False
cmdConnect.Enabled = False
txtName.Enabled = False
End Sub
Private Sub wsChat_Connect()
Do
DoEvents
Loop Until wsChat.State = sckConnected Or wsChat.State = sckError
If wsChat.State = sckConnected Then
'Tell the user that the connection has been established
AddText "----- Connection Established -----" & vbCrLf, txtIn
cmdSend.Enabled = True
txtName.Enabled = False
txtOut.SetFocus
Else
'Tell the user that the connection has been established
AddText "----- Connection Failed -----" & vbCrLf, txtIn
End If
End Sub
Private Sub wsChat_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
If Number <> 0 Then
AddText "----- Error [" & Description & "] -----", txtIn
Call cmdClose_Click
End If
End Sub
Introduc IP-ul si user-ul si dupa ce dau connect imi da eroare la linia AddText "----- Error [" & Description & "] -----", txtIn de mai sus ()
de tipul run time error '13' Type mismatch
Cand pun mouse-ul peste Description imi arata ca description = "Connection is forcefully rejected"
valoarea lui description este de tip string si nu inteleg de ce nu o afiseaza in textboxul txtIN ?