Sie sind auf Seite 1von 20

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

Ads by Google

Visual Basic

VB

VB6 to VB Net Client Server

Visual Basic 6 (VB6)


Home Tutorials

Search

A Client server Chat program using the W insock control


In this tutorial we will learn how to write a simple client server chat program in Visual Basic 6 using the Winsock control. We will right both the server and client side of this program. One of the ways computers can communicate to each other through the internet is by using TCP/IP. In windows there is a Winsock.dll that programmers can leverage to help in this communication. This DLL is very annoying to use in Visual Basic. Luckily, we can use the Winsock control instead - which wraps a lot of the Winsock.dll commands into an easy control for us. You might want to download the source code for this tutorial . To start lets create the client side of our program. Open a new Visual Basic 6 Project (Standard EXE). In order to use the Winsock control we must add it to our toolbox. You can do this by selecting Project -> Components from the menu bar or by pressing Ctrl-T. Then click the check box next to the Microsoft Winsock Control 6.0. Level:

PDF Writer for VB www.synactis.com Create, display, print, edit, merge Royalty-free distribution. Try now!

Now on Form1 create the following controls with the following property values

1 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

Type: Winsock Name: sockMain Type: TextBox Name: txtHost Text: 127.0.0.1 Type: TextBox Name: txtPort Text: 12345 Type: TextBox Name: txtStatus MultiLine: True ScrollBars: 3 - Both Type: TextBox Name: txtSend Type: CommandButton Name: cmdConnect Text: &Connect Type: CommandButton Name: cmdSend Text: &Send Add some labels to organize stuff and arrange your form to look something like this:

Now lets write our code Double click on the Connect button and add this code: Private Sub cmdConnect_Click() sockMain.RemoteHost = txtHost.Text

2 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

sockMain.RemotePort = txtPort.Text sockMain.Connect End Sub This code is pretty easy to follow. We just setup our socket to point to the remote host specified and the remote port, and then we tell it to connect. Next wire up the Send button: Private Sub cmdSend_Click() sockMain.SendData txtSend.Text End Sub Again very simple, all we do is Winsock control to send the data we want it to. Next we will want to receive data when the other person sends it to us. The Winsock control again makes this easy. Every time data arrives the Winsock controls DataArrival event will fire. So lets wire in our code for that. Private Sub sockMain_DataArrival(ByVal bytesTotal As Long) Dim strData As String

sockMain.GetData strData, vbString txtStatus.Text = txtStatus.Text & _ strData & vbCrLf End Sub So in this event we call sockMain.GetData. This method takes two parameters. The first is the variable to store the data in. The second is what type this variable is. Once we have our strData variable filled we append it to status textbox. Server Side of VB6 Program Now lets create the server side of our program. Normally you would create a new Visual Basic program just for the server, but to make things easier we are just going to create a second form. So add a Form2 to your project. And add these controls to it. Type: Winsock Name: sockMain Type: TextBox Name: txtPort Text: 12345 Type: TextBox Name: txtStatus MultiLine: True ScrollBars: 3 - Both Type: TextBox Name: txtSend Type: CommandButton Name: cmdListen Text: &Listen Type: CommandButton

3 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

Name: cmdSend Text: &Send The way a client server relationship works is that the server listens on the port specified. Then when a remote computer (the client) connects to that server at the specified port the server creates a connection with the client and they can communicate back and forth. This is why the server does not have a txtHost text box - because he will listen for any computer that wants to connect. So lets write our Listening code: Private Sub cmdListen_Click() sockMain.LocalPort = txtPort.Text sockMain.Listen End Sub Thats it - when the user presses the listen button sockMain will start listening on the port specified. Now lets move on in our tutorial. Next we will write the code to handle an incoming connect. When someone connects to the port we are listening on we have to decide what to do with him. We do this in the Winsock controls ConnectionRequest event. Private Sub sockMain_ConnectionRequest(ByVal requestID As Long) If sockMain.State <> sckClosed Then sockMain.Close End If

sockMain.Accept requestID

txtStatus.Text = txtStatus.Text & _ "Accepted connection from: " & _ sockMain.RemoteHostIP & vbCrLf End Sub The Socket controls ConnectRequest event passes with it a requestID - this identity's who is trying to connect. This is very useful if you are allowing more than one connection. Since in this basic tutorial we are only allowing one person to connect at a time our code is very simple. First we check to see if the connection is already open we just accept the connection. Then we write a line to our status box se we know. Lastly lets wire up our send button and our data arrival event for Form2 like we did for Form1: Private Sub cmdSend_Click() sockMain.SendData txtSend.Text End Sub

Private Sub sockMain_DataArrival(ByVal bytesTotal As Long) Dim strData As String

sockMain.GetData strData, vbString txtStatus.Text = txtStatus.Text & _ strData & vbCrLf End Sub Also add a quick line of code in the Form1 load event to show Form2 as well. Private Sub Form_Load() Form2.Show

4 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

End Sub Now lets test out our program. Press F5 to run it. Then click the listen button on our server (Form2). Next click the connect button on our client (Form1). Now the two forms can chat back and forth. If you would like you can download the source code for this tutorial . This tutorial explained how to create a simple client server connection. If you would like to expand upon this make a server that allows multiple clients to connect to it check out this tutorial: A multiple client server chat program using Winsock control.

PDF Writer for VB www.synactis.com Create, display, print, edit, merge Royalty-free distribution. Try now!

Similar links
Creating PDF files in Visual Basic VB6 Animated Charts (With FusionCharts) VB6 Downloads Make a Club Penguin Trainer Convert C Strings to VB Strings Activate Any Window With API VB6 Programming Standards VB6 Naming Conventions Naming Database Objects Access SQL 101050 reads

424 run time error


hey im getting "424 run timr error " on connect. also what port no shud i include???/ waitn 4 ur reply>>>!!! reply

Fri, 09/23/2011 - 02:18 Anonymous (not verified)

5 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

Heavy programming in the VB6 DataArrival event causes hangs

Fri, 09/09/2011 - 08:59 Johnag (not verified)

I am upgrading an existing VB6 program to use a socket interface. I have experienced ongoing hangs which I have narrowed down to having a heavy programming path (e.g. DB access) in the DataArrival event. I have tried using a memory queue and a timer to fire off another thread but I still get hangs. It appears that if the program is too busy to process the DataArrival event the interface to TCP just hangs and only the task manager can kill the process. Any ideas on how to get round this? reply

Inquiry?

Mon, 07/25/2011 - 17:35 Aries (Junior Programmer) (not verified)

is Winsock control support external network? i mean outside my Local area network..... is it possible i can access my database in my server if I'm trying to Connect outside my local area network... i did a simple system.. its working on my LAN network. NO PROBLEM.. its working fine... but when it comes to WLAN it sucks.. guys.. need HELP.. give me some examples.. or demo on how to set my simple system.. so i can connect to my database anywhere.. or send me and email aries.suson@yahoo.com tnx in advanced. reply

thank u it was so
thank u it was so usefull specially "If Winsock2.State <> sckClosed Then Winsock2.Close" reply

Sun, 07/10/2011 - 09:59 Anonymous (not verified)

Umm ya i get a 424 error


Umm ya i get a 424 error reply

Sat, 04/23/2011 - 10:03 Anonymous (not verified)

sckClosed and sockMain.State are having errors

Wed, 04/20/2011 - 03:03 JTAlice (not verified)

when i implemented the winsock connection request, it gave me error messages; "'state' is a type in ' AxMSWinsockLib.Axwinsock and cannot be used as an expression" and "'sckclosed' is not declared" what type of variable is this going to have. I am using vb2008. Thanks reply

6 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

Via Online

Tue, 03/29/2011 - 06:33 element666 (not verified)

hi! just would like to ask.. can i connect two computers using internet?? i mean can it be online? or only LAN? thanks reply

i like the tutoria


God willing. thanks reply

Mon, 02/28/2011 - 15:54 MD (not verified)

i just want to say, i am enjoying this, infact, i have gained so much from this tutoria and i hope to contribute some day,

Vb6 Crashing
When i compile, run, or Exit Vb6 Crashes..... What do I do,,,,,,,,,,,,,,,,But great tutorial.... reply

Fri, 02/18/2011 - 07:16 vpayb2000 (not verified)

Do you know how to put buzz alert, stealth settings?

Mon, 12/27/2010 - 19:54 Hokage (not verified)

Do you know how to put buzz alert, stealth settings,file transfer and webcam to this chat program??? reply

that missing Winsock OCX


Found a solution here -

Sun, 10/03/2010 - 06:43 IDEhell (not verified)

http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/93ff8529-3540-47b3-a05a-2c8a81922f40 it seems to work, as has added the component to the form toolbox. Takes a while to load all the components in before selection can be made. Right-click on the open form Toolbox menu, and select 'Choose items...', when it loads select the Microsoft Winsock Control from the COM tab, and it'll be added to the Toolbox. reply

um there's no Winsock control

Sun, 10/03/2010 - 06:17 2010isfucked (not verified)

Using Visual Studio 2010 Professional - there's no Winsock Control to select on any of the form components,

7 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

and the online search for components can't find anything with 'winsock' in it either. Is it renamed in 2010? Can something else be used instead? reply

RE: um there's no Winsock control

Thu, 08/04/2011 - 17:13 Anonymous (not verified)

There is no Winsock component in 2010, as it's been not available ever since VB programming came to use the .NET Framework. Now you have to use the System.Net namespace built-in. It's been giving me problems ever since I started using Visual Basic 2008, where it was easier to do with VB6. reply

Hello

Wed, 09/08/2010 - 04:10 Anonymous (not verified)

Why is the remote host set to 127.0.0.1 can I change i to send via LAN on another computer reply

127.0.0.1 is a loopback

Tue, 02/01/2011 - 01:58 jhE (not verified)

127.0.0.1 is a loopback address. Meaning, you can only sent data to your own PC unit. Yes, you can use other IP address to access the other PC unit that is a member of the Network. But make sure that the IP address is a valid address! reply

Anyone tell me how to do

Sun, 03/28/2010 - 09:28 Anonymous (not verified)

Anyone tell me how to do this with AxMSWinsock 2005? I am using VB 2008. Errors on ConnectionRequest, RequestID is not part of the object; If sockMain.State <> sckClosed Then isn't correct. reply

WinSock with LAN connected to Internet


The Tutorial is great.

Tue, 03/23/2010 - 13:31 Faisal (not verified)

How can data be send from one computer using LAN connected to Internet at server, to another computer connected to internet using Winsock control Thanks reply

8 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

Grate Tutorial
Hey! Gr8 Tutorial for Newbies just like me :). Working fine.Keep it Up. reply

Sat, 02/27/2010 - 07:06 Himal (not verified)

multi-client
thnx for the code i want to ask one thing...... how can i modify this application so that there is one server and 10 clients

Sat, 02/13/2010 - 04:05 subodh (not verified)

so that each client can directly communicate with the server........not with the other clients. plz reply as soon as possible. reply

RE: multi-client
client, just leave it as-is. reply

Thu, 08/04/2011 - 17:15 Anonymous (not verified)

You'd have to make a control array with the Winsock controls, to accept each connection, for the server. As for the

hi, I want 2 ask u is it


maintained by server if yes then how is it possible

Thu, 02/04/2010 - 22:41 shikha (not verified)

hi, I want 2 ask u is it possible that the data v are sending 2 the server or remote host can be saved in a database my project requires the client machine 2 send department and employee details on server machine which should then be saved! reply

RE: hi, I want 2 ask u is it

Thu, 08/04/2011 - 17:17 Anonymous (not verified)

You'd have to code the server to directly access the database, or use a external application that does the database. reply

9 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

local network chatting


over the network using this system..thanks..:) reply

Wed, 01/27/2010 - 05:26 Anonymous (not verified)

hey, i tried your code and it worked great, however, i wanna ask about the code on how to chat with other work stations

Runtime error 40006

Mon, 01/18/2010 - 02:17 Babuji (not verified)

If i tried with two pc chat application worked,But i cann't send the message from one more pc in this network.I am getting "Wrong protocol or connection state for the requested transaction or request" error while sending message from another user's pc,at the same time two person can chat. How can i resolve this error. reply

People who are getting 40006


I noticed that his code doesn't have the code to prevent that. If you want the answer to this... Make sure you do not forget the "if winsock1.state <> sckclosed then winsock1.close" and above that include the line "On error resume next" Should be good then. :] reply

Fri, 11/27/2009 - 00:42 Indulgence (not verified)

That simply means that the socket is still connected and you're trying to reconnect as it's still connected.

Watch Accessories
Watch Accessories Watch Batteries Watch Battery reply

Thu, 11/26/2009 - 20:11 Watch Accessories (not verified)

this code is very simple to


Thanks a lot. reply

Tue, 08/25/2009 - 03:04 Anonymous (not verified)

this code is very simple to understand and you have made it step by step so that a newbie can easily learn the concept.

Error 40006

Thu, 07/30/2009 - 00:17 Anonymous (not verified)

I just hope this is not quite late..I guess there is no problem in the codes, the thing is click first the listen button of the server form to open the port for any request..I hope I did help somebody..thanks!

10 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

reply

10 minutes, from scratch to tested

Tue, 07/07/2009 - 14:39 Anonymous (not verified)

As it's already late here, i'll look at the more advanced version tomorow, than maybe add some stuff for my friends and I. Your tutorials make transition from VB3 (that I was using many many YEARS ago) very smooth. Good job, I'll click on the commercial banners as a thank you ;) reply

Send & Get Text


Hi im sorry for my english lanquge not good . i want to bold or italic text and send to client or server how in client or server get text with bold or italic ,... shap Tnx reply

Thu, 06/04/2009 - 00:00 Radan (not verified)

CHat Appication

Mon, 05/25/2009 - 04:14 Appu (not verified)

Hi,Actually i have tried this application,it is working fine on my machine .But i have built two exe and Server exe is placed on my friend's machine (which is in network).Client exe is placed at my system.In Host text box i have added IP address of my machine and port number.My friend added port number and clicked on Listen then i clicked on Connect still it is giving error "40006" Please tell me what to do??? reply

ggfg
fsfss reply

Mon, 04/13/2009 - 09:55 Anonymous (not verified)

run-time error 40020


how to fix run-time error '40020'? reply

Mon, 01/19/2009 - 01:58 Anonymous (not verified)

11 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

abc
By closing that program you can avoid this type of errors reply

Tue, 04/12/2011 - 02:45 Anonymous (not verified)

error Runtime 40020

Mon, 01/19/2009 - 01:37 Anonymous (not verified)

how to fix this problem "run-time error'40020' : invalid operation at current state reply

40006 error
I keep getting the 40006 error message; I think it Might Be the IP Port. How Can I Change My IP address reply

Tue, 11/25/2008 - 06:34 KOBZEN (not verified)

Run time Error 40006


Hi!

Tue, 11/11/2008 - 09:08 Run time Error 40006 (not verified)

I tried all options to get rid of this run time error 40006 but still occuring.Please tell me what should i do. Thanks in advance. reply

Run-Time Error 40006

Fri, 10/10/2008 - 12:13 sa (not verified)

i get runtime error 40006 "wrong protocol or connection state for the requested transaction or request." when i lcik the send button on both client and server. This happens in the source code download aswell. How can i fix it? On both when i click debug it hightlights the cmdSend section of the code. reply

cmdSend_click() error fix


change this: Private Sub cmdSend_Click() sockMain.SendData txtSend.Text End Sub TO THIS:

Thu, 10/23/2008 - 21:26 LongJohnSilver (not verified)

12 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

Private Sub cmdSend_Click() sockMain.SendData (txtSend.Text) End Sub its works then. reply

Winsock

Wed, 10/15/2008 - 09:25 Bob (not verified)

I am getting the same error message. I have tried everything, including upgrading to SP6. Have tried other versions of the same type of code from msdn, but still the same problems. I am at a loss. reply

hey
problems with this one. reply

Sun, 10/05/2008 - 06:41 vbsstalker (not verified)

Ummmmm I did this once using your steps and worked beautifully. Thx tried using Youtube and always got an error. No

Port
Dear, sorry for my stupid questions :

Tue, 09/02/2008 - 08:22 Maurizio (not verified)

- the 127.0.0.1 in the example is the local host (my PC?) and the port number is just a virtual one (always on my PC?) - in real case, what have I to set up on my server (IP: 62.149.140.18) - which port have I to assign for chatting? - asked my provider, I was told that with shared hosting I cannot set-up any special port - does it exist on internet some service letting me to use their server and a reserved port for my private cha application? Thank you in advance. Maurizio Ammannato reply

NETWORK PROTOCOL
IP: 62.149.140.18? why use a "class A" network Protocol?

Tue, 02/01/2011 - 02:12 Anonymous (not verified)

IF YOU WILL USE IT ONLY FOR LESS THAN 30 COMPUTER UNITS, JUST USE "CLASS C" network Protocol. CLASS C: 192.0.0.1 ABOVE. reply

13 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

Name
then says what they want to say... reply

Fri, 08/29/2008 - 03:24 afafs (not verified)

i got a name box in my chat. how do you get the name to say when you connect and speak? like msn it says the name

Name

Fri, 08/29/2008 - 03:53 afafs (not verified)

i got the answer already but i cant get the things i type to go into my own text box like in form 2... i have a box called txtStatus and when i type stuff into txtSend and press send it just sends it to the other person i am talking to not me. plz help reply

It only sends it to the

Fri, 08/29/2008 - 09:07 Admin

It only sends it to the other person because that is what the code tells it to do. Why don't you in the send buttons click event have it send the text to the other person and then simply append that text to your text box? reply

NVM

Fri, 08/29/2008 - 18:42 afafs (not verified)

nvm i got it to work but my close function... dosent work. i use the same prog for the 2 person chat and when i connect then close it only tells ME that the connection is closed but the other perrson dosent reply

some help

Thu, 12/18/2008 - 08:20 Ovhan beginner (not verified)

well i did it so that it is like this , when you hit the button it adds it in front of it as it goes into the main chat area , i m not on my vb6 pc atm but i think the code is something like this, private sub cmdsend_click() dim text&name as string text&name = vbcrlf & name & ":" & txtsend.text ' and then it goes something like the original code sockmain1.senddata (text&name) ' or whatever that is supposed to be , hope it helps reply

I am new

Tue, 08/26/2008 - 22:09 chazzm

14 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

Just getting back into this after being out a while!! When I run this script, I keep getting a complie error "varible not defined" In the area marked by the astrix ""Private Sub cmdConnect_Click() sockMain.RemoteHost = txtHost.Text sockMain.RemotePort = txtPort.Text sockMain.Connect End Sub Private Sub cmdSend_Click() *****Private Sub Form_Load() Form2.Show txtStatus.Text = "" End Sub****** Private Sub sockMain_DataArrival(ByVal bytesTotal As Long) Dim strData As String sockMain.GetData strData, vbString txtStatus.Text = txtStatus.Text & _ strData & vbCrLf End Sub Winsock sockMain It will list the txtStatus.Text ="" as the varible not defined???? Can someone explain this to me?? Or what I'm missing?? reply

My Opinion

Sun, 08/17/2008 - 21:42 vbPortugal

This is very good and works, if you are having problems with the 40006 error like I did just read the comments ;) reply

end connection?

Wed, 08/13/2008 - 01:26 Anonymous (not verified)

what would the code be for a button to terminate the connection, instead of having to close the program each time? reply

Just add a button and in the


Just add a button and in the click event call sockMain.Close() reply

Wed, 08/13/2008 - 11:07 Admin

15 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

thanks for the reply..is

Mon, 08/11/2008 - 18:39 Anonymous (not verified)

thanks for the reply..is there any way to use winsock control and create client server netwrking?im new to vb,.. reply

im using vb 2005....can i

Mon, 08/11/2008 - 01:10 feena (not verified)

im using vb 2005....can i use this code for vb 2005..i have try them out...but there a few errors saying... 1) Error 1 'State' is a type in 'AxMSWinsockLib.AxWinsock' and cannot be used as an expression. 2) Error 2 Name 'sckClosed' is not declared. can pls help me if there's another way of doing this..thank you.. reply

This code will only work

Mon, 08/11/2008 - 06:55 Admin

This code will only work with VB6 - sorry. I am working on VB.NET version of this website, but it will probably be a while before its done. Check out my review of this VB.NET Tutorial site. You might find it helpful. reply

How can you tell...


something totally different Also... There is a problem in the code: If sockMain.State <> sckClosed Then sockMain.Close() End If It Highlights SockMain.State and sckClosed

Fri, 07/10/2009 - 08:58 Anonymous (not verified)

How can you tell what version you have? Mine says Visual Basic 2008 Express Edition. Is that VB6, VB.Net or

It says something about SockMain.State cannot be used in an expression. And sckClosed not defined. Should I update my code??? reply

I was just wondering if it

Sat, 08/02/2008 - 10:13 Anonymous (not verified)

I was just wondering if it was possible for you to add how to use screen names so that it isn't confusing when people type, and also so you are able to see your own text when you send it out. Overall good tut :)

16 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

reply

uh this sux...
a online server reply

Fri, 05/30/2008 - 16:30 Anonymous (not verified)

this one isnt so good...i saw a better one but you cannot use this with 2 computers. I need to no how to connect and build

forgot...
convosation.

Thu, 05/22/2008 - 04:06 SatansPriest (not verified)

hi just to let you know you forgot to put txtStatus locked=true if you dont do that you could easly lose all your and i was wondering if you could tell me how to make a line break after each message and maybe time the message was sent? P.S thanks so much for all the help iv been wanting to do this for ages. i love your website reply

just add a text box and on


just add a text box and

Tue, 06/15/2010 - 21:46 ThePitbull (not verified)

on your send it should look something like this double click the textbox u use for chatting and paste this in Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 'if we press enter then send text and clear the chat textbox after text is sent to the chat Winsock1.SendData (Nick.Text + ":" + ChatSend.Text)' u will need to put the correct names of your textboxs where mine are called nick & chatsend ChatSend.Text = "" 'this will allow u to put a Nickname in one textbox and type in another i.e) Nick:Hello all .how is everyone? reply

Nice
This will help when I code the multiplayer part of my game. ~ZaerTheDraconian~

Thu, 05/10/2007 - 19:42 Zaer

PS: Would it be possible to put chat in a listbox? It would be easier to add chat items that way. Also, would it be possible to put the cmdListen Click code in Form Load? Thanks in advance. reply

17 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

Run-Time Error 40006

Mon, 04/30/2007 - 01:17 Roda

i get runtime error 40006 "wrong protocol or connection state for the requested transaction or request." when i lcik the send button on both client and server. This happens in the source code download aswell. How can i fix it? On both when i click debug it hightlights the cmdSend section of the code. reply

Sorry

Mon, 04/30/2007 - 08:48 Admin

Sorry I probably should have explained this. First you need to Click the Listen button on the server. This will start the server listening. Then press the connect button on the client. This will tell the client to connect to the server. Once those connections are made then you can send stuff back and forth. Hope this helps. reply

2 exe's

Sun, 05/06/2007 - 09:30 Anonymous

How do you make 2 different exe's? such as i have the server.exe and they have the client.exe Thx in advance reply

Two exe's
2 different files Thx reply

Sun, 05/06/2007 - 09:28 Anonymous

How do you make 2 exe's so that i have the server.exe and they have the client.exe? Please tell me how to make

18 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

Dump
Dear I Think You Are New In VB For Server:-

Tue, 07/24/2007 - 00:14 Anonymous

To Create Two Exe For This Lovely Application simply Make Sure that the Form you wants to use as server sud be at start up of project For Client:To Create Two Exe For This Lovely Application simply Make Sure that the Form you wants to use as Client sud be at start up of project to do this Go to Project>>Project1 Properties>>>startup opject .... reply

How to make two Exe's


Open each form separately and compile them to exe's. reply

Mon, 07/02/2007 - 17:13 Anonymous

using two text box...


advanced reply

Wed, 05/25/2011 - 03:30 Anonymous (not verified)

how can i use it in two text or more box to send and in other pc two or more textbox to recieve?? thx in

Post new comment


Your name: Anonymous E-mail:
The content of this field is kept private and will not be shown publicly.

Homepage:

Subject:

Comment: *

19 of 20

10/11/2011 1:37 PM

A Client server Chat program using the Winsock control | Visual Basic 6 ...

http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-co...

Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> Lines and paragraphs break automatically.

More information about formatting options

Preview

Unless otherwise noted, all content on this site and in the source samples is Copyrighted 2011 by the owner of vb6.us. All rights reserved - Contact Information

20 of 20

10/11/2011 1:37 PM

Das könnte Ihnen auch gefallen