Step 5Coding the command buttons
lets start with the first one cmdHost
1. double click it, this will bring up the code window
2. it should look like this
Private Sub cmdHost_Click()
End Sub
3. enter this code
sckMain.LocalPort = txtPort.text
sckMain.listen
now what does that mean??
the first line makes the winsocks local port equal the number in the textbox (txtPort)
the second line tells the winsock to listen on that port for someone trying to connect
now close that and double click on cmdConnect
enter this code
sckMain.RemoteHost = txtIP.text
sckMain.RemotePort = txtPort.text
sckMain.Connect
the first two lines change the RemoteHost and the RemotePort of the winsock (sckMain) to the ip and port we want
the sckMain.Connect tells it to connect to someone listening on that port and ip
now for the close button
double click on cmdClose and type
sckMain.close
txtLog = txtLog.text & "Connection closed!" & vbCrlf
the sckMain.close tells the winsock to disconnect
the second line adds Connection closed to txtLog
double click on cmdSend and type
sckMain.senddata "[" & txtName.text & "]" & txtSend.text
txtLog = txtLog.text & "[" & txtName.text & "]" & txtSend.text & vbcrlf
txtSend.text = ""
the first two lines are wrong i have them right in the editor and it changes them when i save so look at the picture for the right code
first line sends the text in txtSend and your name in txtName
second line adds the message you sent and your name to txtLog
third line clears the text in txtSend
| « Previous Step | Download PDFView All Steps | Next Step » |











































Like chat aplication generally, example: Facebook chat.
Thanks
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
Dim proCedure As String
sckMain.SendData("[" & txtName.Text & "]" & txtSend.Text)
proCedure = txtLog.Text & "[" & txtName.Text & "]" & txtSend.Text & vbCrLf
proCedure = txtLog.Text
txtSend.Text = ""
Dim proCedure As String
sckMain.Close()
proCedure = txtLog.Text & "Connection closed!" & vbCrLf
proCedure = txtLog.Text
2 additional lines of code doing the same thing that gets rid of an error.
http://support.microsoft.com/kb/290887
Private Sub cmdSend_Click()
sckMain.SendData "[" & txtName.Text & "]" & txtSend.Text
txtLog = txtLog.Text & "[" & txtName.Text & "]" & txtSend.Text & vbCrLf
txtSend.Text = ""
End Sub
program it says that it has a run time error and it requires an object how can i fix that?
is error in my vb
sckMain.close(this close)
txtLog = txtLog.text & "Connection closed!" & vbCrlf
what to do?
tnx