Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

winsock/chat help

Status
Not open for further replies.

byan

Technical User
Jul 31, 2002
6
US
well i went ahead and atempted to make this chat program-,
I ran into to problems:
the textbox wouldn't go down to the next line
the connecting client would freeze

here is my code:
Private Sub cmdsend_Click()
If txtsend.Text <> &quot;&quot; Then
ws.SendData (&quot;ch&quot; + txtname.Text + &quot;: &quot; + txtsend.Text)
txtcon.Text = txtcon.Text & vbCrLf & txtname.Text + &quot;: &quot; + txtsend.Text
txtsend.Text = &quot;&quot;
txtsend.SetFocus
End If
End Sub

Private Sub Form_Load()
Dim Received As String
Dim Data As String
If ws.LocalIP = &quot;127.0.0.1&quot; Then
MsgBox &quot;NOTE: You are not connected to the internet&quot;, vbCritical, &quot;ERROR- NO CONNECTION&quot;
End If
Label3.Caption = &quot;Your IP Address is: &quot; + ws.LocalIP
End Sub

Private Sub ws_ConnectionRequest(ByVal requestID As Long)
ws.Close
ws.Accept requestID

txtcon.Text = txtcon.Text & vbCrLf & &quot;----- Connection Established -----&quot;
cmdsend.Enabled = True
txtname.Enabled = False
txtsend.SetFocus
End Sub

Private Sub ws_DataArrival(ByVal bytesTotal As Long)
ws.GetData Received
Select Case Left$(Received, 2)
Case &quot;ch&quot;
Data = Right$(Received, Len(Received) - 2) & vbCrLf
txtcon.Text = txtcon.Text & vbCrLf & Data
End Select
End Sub

Private Sub ws_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
txtcon.Text = txtcon.Text & vbCrLf & &quot;----- Error [&quot; & Description & &quot;] -----&quot;
Call cmdclose_Click
End If
End Sub


I do no see what is wrong
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top