PDA

View Full Version : Simple Client Chat Program(VB6)WinSocket


jvx
11-21-2008, 04:58 AM
Needed:
Visual Basic 6
Make Standard EXE
Create 2 Forms
4 text boxes
2 labels
2 command buttons

Result:
http://i444.photobucket.com/albums/qq164/joshjeffreytk/dodian/chat.jpg


Code:

Form1:
Option Explicit

Private Sub cmdConnect_Click()
sockMain.RemoteHost = txtHost.Text
sockMain.RemotePort = txtPort.Text
sockMain.Connect
End Sub

Private Sub cmdSend_Click()
sockMain.SendData txtSend.Text
End Sub

Private Sub Form_Load()
Form2.Show

txtStatus.Text = ""
End Sub

Private Sub sockMain_DataArrival(ByVal bytesTotal As Long)
Dim strData As String

sockMain.GetData strData, vbString
txtStatus.Text = txtStatus.Text & _
strData & vbCrLf
End Sub


Form 2:
Option Explicit

Private Sub Form_Load()
txtStatus.Text = ""
End Sub

Private Sub cmdListen_Click()
sockMain.LocalPort = txtPort.Text
sockMain.Listen
End Sub

Private Sub sockMain_ConnectionRequest(ByVal requestID As Long)
If sockMain.State <> sckClosed Then
sockMain.Close
End If

sockMain.Accept requestID

txtStatus.Text = txtStatus.Text & _
"Accepted connection from: " & _
sockMain.RemoteHostIP & vbCrLf
End Sub

Private Sub cmdSend_Click()
sockMain.SendData txtSend.Text
End Sub

Private Sub sockMain_DataArrival(ByVal bytesTotal As Long)
Dim strData As String

sockMain.GetData strData, vbString
txtStatus.Text = txtStatus.Text & _
strData & vbCrLf
End Sub

Private Sub txtStatus_Change()

End Sub

firezone99
11-21-2008, 05:02 AM
ok ty lol but i dun hav any of those=p dont wanna download anyway ty=] nice guide=]

Arsenal
11-21-2008, 05:24 AM
You can make better chats using Java.

jvx
11-21-2008, 05:57 AM
You can make better chats using Java.

With the way java is going. you make litterally anything Better LAWL! =p

evelstar7
12-20-2008, 03:10 PM
how do you make an exe

D I N O
12-22-2008, 08:44 PM
Very good coding mate. prehaps you could add a little colour?

~D I N O

Zaga
12-27-2008, 03:59 PM
i like it thanks

ToshiXZ
12-27-2008, 04:03 PM
~Leached, I've seen this tutorial xD Google Chat over LAN and you'l eventually find it xD

l3g1t pker
12-16-2009, 04:47 AM
Very nice, I think that you could add some download links to the "needed" list though.