Welcome, Bloggers.
On this page, we will explain how to make a simple chat application using
Visual Basic.
First step, open the Visual Basic application. The following window will appear:
In this window,
please select the icon "Standard EXE" and click "Open". Window
will appear as follows:
Furthermore, the
components we need are:
[+] Label
[+] Command Button
[+] Textbox
[+] Winsock
Did not find Winsock component?
Yes, these components are not available directly as the three components above.
So we need the addition of a component by selecting Project -> Components on
the menu bar. The following window will appear:
In this window,
find the component named Microsoft Winsock Control 6.0. check on the left. Click
Apply and OK. Winsock component will then appear on the main page.
Furthermore, the component is ready. Then we will start from the zoom.
Please create a screen similar to the following:
The following window:
Display above has
4 Label component, component 5 Command
Button, Textbox component
5, and 2 Winsock components.
For simplicity, please change the
name (name) of
each component. The name can be changed by
clicking on the component and the properties window will appear on the line (name). 
if the display
is completed , the next section we finish the program listing .
Listing of the following programs :
Private Sub Connect_Click ( )
Winsock_client.Connect
end Sub
Private Sub Send_Click ( )
Winsock_client.SendData Winsock_server.LocalHostName & " : "
& Text4.Text
Text5.Text = Text5.Text & vbCrLf & Text4.Text
end Sub
Private Sub Disconnect_Click ( )
Winsock_server.Close
Winsock_client.Close
Label6.Caption = " Disconnected "
Text1.Visible = True
Text2.Visible = True
end Sub
Private Sub Test_Click ( )
Winsock_server.LocalPort = Text3.Text
Winsock_server.Listen
end Sub
Private Sub OK_Click ( )
Winsock_client.RemoteHost = Text1.Text
Winsock_client.RemotePort = Text2.Text
end Sub
Private Sub Text1_gotfocus ( )
Text1.Text = " "
end Sub
Private Sub Text2_gotfocus ( )
Text2.Text = " "
end Sub
Private Sub Text4_Click ( )
Text4.Text = " "
end Sub
Private Sub Winsock_client_Connect ( )
Status.Caption = " Status : Connected"
end Sub
Private Sub winsock_server_ConnectionRequest ( ByVal requestID As Long )
Winsock_server.Close
Winsock_server.Accept requestID
end Sub
Private Sub winsock_server_DataArrival ( ByVal bytesTotal As Long )
As String Dim chat
Winsock_server.GetData chat
Text5.Text = Winsock_server.LocalHostName & " : " & vbCrLf
& Text5.Text & chat
end Sub
Display finished , completed listings . Next run the program .
Good luck .