3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

How to make a simple chat program in visual basic using the Microsoft Winsock Control

How to make a simple chat program in visual basic using the Microsoft Winsock Control
In this instuctable i will show you how to make a simple chat program in visual basic. i will go over what all the code does so you will be learning as you make it, and at the end i will show you how to use it.
 
Remove these adsRemove these ads by Signing Up
 

Step 1Overview

Overview
This program will let you exchange messages between two people on your same network. It may work if your not on the same network but i can't test it now.

You should have Microsoft Visual Basic 6.0, that is what i am using.
Basic programing knowledge is recommended

Lets get started!!!

open visual basic and create a Standard EXE
« Previous StepDownload PDFView All StepsNext Step »
216 comments
1-40 of 216next »
May 4, 2012. 3:04 AMothmanmohammed says:
i can't download the tut pdf!!
Apr 14, 2012. 11:07 PMCorliansa says:
there is this word in front = "Run-Time Error '40006';
Apr 14, 2012. 10:37 PMCorliansa says:
I can't when i click "Send" button it give this message = "Wrong Protocol Or Connection State For The Requested Transaction Or Request" can you fix it?
Apr 10, 2012. 11:51 PMmarkjeggar says:
A simple VB.NET chat program with source code

http://vb.net-informations.com/communications/vb.net_chat_server_program.htm

jeggr.
Apr 7, 2012. 9:24 PMkumali says:
is it working with at least 3 computers?
May 12, 2009. 8:34 PMde7ox says:
Hi, i am coding in VB2008, it worked so far but this part doesn't work @ all for me :

sckMain.state <> sckClose


sckMain.accept requestid


Please e-mail me with a solution asap as i really like this proggy u made!
de7ox@hotmail.com
Thanks!
Mar 5, 2011. 5:28 PMjflores-3 says:
I created a chat program without winsock and its works
Mar 11, 2011. 5:39 AMjflores-3 says:
the correct code is:If sckMain.CtlState <> 0 Then

sckMain.Accept(e.requestID)
Feb 28, 2012. 12:55 AMsathiprady says:
how is it possible can you explain
Sep 13, 2010. 4:46 PMgurgle528 says:
Dim proCedure As String
sckMain.Close()
sckMain.Accept(e.requestID)
sckMain.Accept(e.requestID)
proCedure = txtLog.Text & "Connected to: " & sckMain.RemoteHostIP & vbCrLf
proCedure = txtLog.Text
you will need to fix the lines, but this is what I have.
Sep 22, 2009. 5:58 AMRoboticProgrammer says:
Winsock1.Close() Winsock1.Accept(e.requestID)
Feb 18, 2012. 9:09 AMMunRa says:
How to make the message sent to ListBox if use ENTER BUTTON on Keyboard?

Like chat aplication generally, example: Facebook chat.

Thanks
Feb 13, 2012. 3:08 AMpradysathi says:
Hai I tried to connect the chat(program which is developed in vb 6) with another system on the LAN. i am finding it hard to do so.kindly help me.
Jan 9, 2012. 10:42 PMHendro_Prayogo says:
Sir ,
Error "40020" how come ?"
plese reply ..
:D
Mar 3, 2010. 12:30 AMhyker69 says:
mr twenglish when i run the program RUN TIME ERROR Occurs and says it Requires an Object how can i fix that?..pls reply until tommorow because im rushing our project tnx..pls teach me how to fix that problem..tnx again..

Jan 4, 2012. 4:09 PMark_anghel07 says:
Successfull.. tnx
Oct 23, 2011. 1:52 AMembivert says:
Hi,
I'm paras. I've never tried to run the above program but the way of describing the example is awesome.
Sep 29, 2011. 5:32 AMMochamaddhany says:
I have run-time error "40020" invalid operation at current state
Aug 30, 2011. 6:37 PMmhimebaugh says:
Operator "&" is not defined for types "String" and "System.Windows.Forms.Textbox"
This message will appear when entering the code for cmdSend. This is the exact code I typed in
Private Sub cmdSend_Click()
sckMain.SendData("[" & txtName.Text & "]" & txtSend.Text)
txtLog = txtLog.Text & "[" & txtName & "]" & txtSend.Text & vbCrLf
txtSend.Text = ""
End Sub
Aug 30, 2011. 6:51 PMmhimebaugh says:
Wait Nevermind i used a diffrent code it works now :P
Jul 19, 2011. 8:37 AM2?@8A:5 says:
is it working in WAN i mean like skype or MSN?
Jun 16, 2011. 7:53 AMmsörhäll says:
I need help.
EVERYTHING is working fine, but I want it so when you're active in the txtSend window, and press Enter/Return, it's the same as clicking Send.

So, when I click enter, it will send the message I've typed in the txtSend box.

Thanks!
May 28, 2011. 2:39 PMjormsbee says:
im on vista so i couldn't get visual basics 6 to work
May 28, 2011. 2:39 PMjormsbee says:
im on vista so i couldn't get visual basics 6 to work
May 28, 2011. 2:37 PMjormsbee says:
does anyone know about visual basics 2010? winsock ?
Mar 6, 2011. 7:23 AMlshoko says:
when l run my program it says object missing pliz help
May 19, 2011. 2:37 AMctaniel says:
same object are missing in you program, look up all program and make auto correct
May 8, 2011. 4:17 PManthonyyy0 says:
how do i add winsock to visual basic 2010?
Apr 12, 2011. 5:55 AMnutsandbolts_64 says:
You could try using VPN to test out the "not in the same network" bit.
Apr 6, 2011. 11:55 PMjeff032690 says:
i have an error...kindly please help me..
Argument not optional

Private Sub CMDSEND_Click()
Me.SCKMAIN.SendData = "(" & Me.TXTNAME.Text & ")" & Me.TXTSEND.Text

Apr 10, 2011. 7:41 PMjeff032690 says:
yes..
Apr 10, 2011. 10:26 PMjeff032690 says:
then what should i do..?
Feb 24, 2009. 6:13 PMjustin.samoisette says:
i tried adding Microsoft Winsock but it wasn't in the list. what do i do??
1-40 of 216next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
8
Followers
2
Author:twenglish1
i love working with electronics and computers, playing video games, and i love to play with fire, HACKING!!!!