-
Jan 16th, 2006, 10:42 AM
#1
Thread Starter
New Member
Run Time Error 40020!! Pls Help!
I have write a simple Client/Server program, for multiple client within my home. But when I run the client program, It give me the following Error.
Run Time Error 40020!
My code is below, THanks For your help in advance!
VB Code:
Option Explicit
Private Sub cmdClose_Click()
Socket1.Close
StatusBar1.Panels(1).Text = "Connection Closed"
End Sub
Private Sub cmdConnect_Click()
If Socket1.State <> sckClosed Then
Socket1.RemoteHost = "192.168.0.4"
Socket1.RemotePort = 1007
Socket1.Connect
txtSend.SetFocus
StatusBar1.Panels(1).Width = 1000
StatusBar1.Panels(1).Text = "Connecting to server..."
Else
MsgBox "Error! Connection already exist, Please Close connection before Connect!"
End If
End Sub
Private Sub Form_Load()
Socket1.Connect
End Sub
Private Sub txtSend_KeyPress(KeyAscii As Integer)
Static Last_Line_Feed As Long
If Socket1.State <> sckConnected Then
Dim NewLine As String
If txtSend = vbNullString Then Last_Line_Feed = 0
If KeyAscii = 13 Then
NewLine = Mid(txtSend, Last_Line_Feed + 1)
Last_Line_Feed = txtSend.SelStart
End If
StatusBar1.Panels(1).Text = "Sending Data..."
Socket1.SendData txtName.Text & " >" & NewLine
DoEvents
Else
StatusBar1.Panels(1).Text = "Not Currently Connected!"
End If
End Sub
Private Sub Socket1_DataArrival(ByVal bytesTotal As Long)
Dim data As String
Socket1.GetData data, vbString
txtReceive.SelText = data
End Sub
Private Sub Socket1_SendComplete()
StatusBar1.Panels(1).Text = "Complete Sending Process!"
End Sub
The stops at [Socket1.RemoteHost = "192.168.0.4"]
anyone can help!!!
Last edited by Locus; Jan 16th, 2006 at 08:39 PM.
-
Jan 16th, 2006, 08:43 PM
#2
Thread Starter
New Member
Re: Run Time Error 40020!! Pls Help!
In the "Form_Load" Event, I am using "Socket1.Connect"
Is it because of that?
But I already inlcude
"If Socket1.State <> sckClosed" Statement in the "cmdConnect_Click" Event. why still can not?
Thx!
-
Jan 17th, 2006, 09:29 AM
#3
Frenzied Member
Re: Run Time Error 40020!! Pls Help!
As near as I can tell, when the remote address & port are unknown when the Socket1.Connect line in Form_Load executes. The command may still be trying to complete when you click the Connect button. In that case, the state will not be sckClosed and your code will try to connect again.
If you want to connect only when the user clicks a button, remove the Socket1.Connect line from Form_Load.
If you want to connect when the app loads, you can either
1) change the line Socket1.Connect to cmdConnect_Click in Form_Load, or
2) move all of the connect code to Form_Load.
-
Jan 17th, 2006, 10:39 AM
#4
Thread Starter
New Member
Re: Run Time Error 40020!! Pls Help!
Thanks, ccoder, I do as you told me and it works.
thanks for your help!
-
Feb 4th, 2016, 05:05 AM
#5
New Member
Run Time Error 40020....Pls Help
hello....
Initially, master and slave communicates nicely but after some query and response i am getting error :run time error 40020...
please help me...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|