==============================================================================================
SIMPLE VISUAL BASIC CHATTING APPLICATION BY EVILSOFTS
==============================================================================================
Its very simple to create a chatting application in visual basic if u knws just basic factors and use of controls in visual basic 6.0
here u have to create a "CLIENT" and "SERVER"...where 'client' will work as a chatting application / messenger and 'server' willl perform the sending of "PACKETS" or transaction of data from one client to another one
==============================================================================================
REQUIREMENT : visual basic 6.0 (microsoft winsock control*)
==============================================================================================
we will go systematically...
first let us create a 'CLIENT'
In 'client' we need 'IP' and 'PORT', where this both will be the address of 'SERVER' on which the client is connected to perform chat...

Here 'IP' is > 127.0.0.1
'PORT' is > 123
=============================================================================================
CLIENT CODING :-=============================================================================================
CODE of 'CONNECT' button
Private Sub cmdconnect_Click()
On Error GoTo t
sock1.Close
sock1.RemoteHost = txtIP
sock1.RemotePort = txtPort
sock1.Connect
Exit Sub
t:
MsgBox "Error : " & Err.Description, vbCritical
End Sub
=============================================================================================
CODE of 'WINSOCK' control
Private Sub winsock1_Close()
winsock1.Close 'close connection
txtLog = txtLog & "*** Disconnected" & vbCrLf
End Sub
Private Sub winsock1_Connect()
txtLog = "Connected to " & winsock1.RemoteHostIP & vbCrLf
End Sub
Private Sub winsock1_DataArrival(ByVal bytesTotal As Long)
Dim dat As String
winsock1.GetData dat, vbString
txtLog = txtLog & "Server : " & dat & vbCrLf
End Sub
Private Sub winsock1_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)
txtLog = txtLog & "*** Error : " & Description & vbCrLf
winsock1_Close
End Sub
=============================================================================================
CODE of 'SEND' button
Private Sub cmdsend_Click()
On Error GoTo t
winsock1.SendData txtSend
txtLog = txtLog & "Client : " & txtSend & vbCrLf
txtSend = ""
Exit Sub
t:
MsgBox "Error : " & Err.Description
winsock1_Close
End Sub
=============================================================================================
** CLIENT CODING ENDS HERE **
=============================================================================================

lets move towards 'SERVER' coding...
=============================================================================================
SERVER CODING :-=============================================================================================
CODE for 'LISTEN' button :-Private Sub cmdListen_Click()
On Error GoTo t
winsock1.Close 'we close it in case it listening before
winsock1.LocalPort = txtPort
winsock1.Listen
Exit Sub
t:
MsgBox "Error : " & Err.Description, vbCritical
End Sub
=============================================================================================
CODE for 'SEND' button :-Private Sub cmdsend_Click()
On Error GoTo t
winsock1.SendData txtSend
txtLog = txtLog & "Server : " & txtSend & vbCrLf
txtSend = ""
Exit Sub
t:
MsgBox "Error : " & Err.Description
winsock1_Close
End Sub
=============================================================================================
CODE for 'WINSOCK' controls :-Private Sub winsock1_Close()
winsock1.Close
txtLog = txtLog & "*** Disconnected" & vbCrLf
End Sub
Private Sub winsock1_ConnectionRequest(ByVal requestID As Long)
'txtLog is the textbox used as our
If winsock1.State <> sckClosed Then winsock1.Close
winsock1.Accept requestID
txtLog = "Client Connected. IP : " & winsock1.RemoteHostIP & vbCrLf
End Sub
Private Sub winsock1_DataArrival(ByVal bytesTotal As Long)
Dim dat As String
sock1.GetData dat, vbString
txtLog = txtLog & "Client : " & dat & vbCrLf
End Sub
Private Sub winsock1_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)
txtLog = txtLog & "*** Error : " & Description & vbCrLf
winsock1_Close
End Sub
=============================================================================================
server coding ends here
=============================================================================================
ENJOY THIS CODE AND MAKE UR OWN CHATTING APPLICATION...THIS IS JUST A SIMPLE APPLICATION... SOON I WILL SHARE A MULTI CHATTING SOFTWARE CODE
EVILSOFTS RULZZZZ