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 »
208 comments
1-40 of 208next »
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??
Mar 11, 2011. 5:50 AMjflores-3 says:
find it fin and find until you find it
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)
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)
Dec 9, 2010. 5:23 AMchvkaushik says:
i am new to this field so please help me out unable to understand
Dec 10, 2008. 5:15 AMkevin-a101 says:
PS...im using Visual basic 2008 or 2005...ones at school ones at home (2008).. if u can give me a link to download vb 6.0 i would gladly install that if it helps
Dec 10, 2008. 12:26 PMkevin-a101 says:
ok i have no problem getting it im buying it i should have it in a little but..like i said im probably gonna need you to teach me some stuff im new with connecting the program to servers
Dec 10, 2008. 1:08 PMkevin-a101 says:
ok still downloading but as u can see im monitering posts
1-40 of 208next »

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!!!!