Two Person Chat With The Winsock Control And Visual Basic - Creating the chat form
(Page 2 of 7 )
Start by loading Visual Basic and creating a new standard exe application. Rename form1 to frmMain. To allow our chat application to communicate over the Internet, we need access to the Microsoft Winsock library. We can access this library in two ways. Firstly, by adding a reference to the library from the Project -> References menu option. Secondly, we can add the Microsoft Winsock ActiveX component into our application. The second way allows us to easily create an instantiation of the Winsock library in the form of a control, so we will use this method.
Click on the Projects menu, and then the Components menu item. Scroll down the list of available components and check the "Microsoft Winsock Control 6.0" option:

Click Apply and then the OK button. We've just made the Winsock ActiveX control available to our application. The Winsock control is now part of the controls toolbar and is represented like this:

Now that we have access to the Winsock library, let's create the layout and controls that make up our chat form. In the Visual Basic form designer, our chat form looks like this:

Basically, our chat form is composed of one image, four text boxes and four buttons. The details of each of these controls are shown below:

Don't worry too much about the design and layout of the chat form. The complete source code and a compiled version of the chat application are included with the support material for this article, which is available from the last page.
I will concentrate on describing the most important methods of our application from here on in.
Next: Code from the clients point of view >>
More Visual Basic Articles
More By Jason Brimblecombe