VB 不管怎么修改都提示40006错误,什么原因

服务端:PrivateSubCommand1_Click()Me.Winsock1.SendDataTrim(Text2.Text)EndSubPrivateSubCom... 服务端:

Private Sub Command1_Click()
Me.Winsock1.SendData Trim(Text2.Text)
End Sub

Private Sub Command2_Click()
Text2.Text = ""
End Sub

Private Sub Command3_Click()
Winsock1.Close
End Sub

Private Sub Form_Load()
Winsock1.Listen

End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Accept requestID
Me.Text1.Text = "与控制端连接成功"
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim mys As String
Winsock1.GetData mys
Me.Text1.Text = Me.Text1.Text & mys & vbCrLf
End Sub
客户端:
Private Sub Command1_Click()
Winsock1.RemoteHost = Trim(Me.Text1.Text) '远程计算机的名称或地址
Winsock1.RemotePort = Trim(Me.Text2.Text)
Winsock1.Close
Winsock1.Connect
Command1.Enabled = False

End Sub

Private Sub Command2_Click()
Winsock1.SendData Trim(Text4.Text)
End Sub

Private Sub Command3_Click()
Text4.Text = ""
End Sub

Private Sub Command4_Click()
Me.Winsock1.Close
Me.Command1.Enabled = True
End Sub

Private Sub Form_Load()
Command4.Enabled = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
Winsock1.Close
End Sub

Private Sub Winsock1_Close()
Winsock1.Close
End Sub

Private Sub Winsock1_Connect()
Me.Text3.Text = "与被控端连接成功!" & vbCrLf
Winsock1.SendData Winsock1.LocalIP '返回本地机器的 IP 地址
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim mys As String
Winsock1.GetData mys
Me.Text3.Text = Me.Text3.Text & mys & vbCrLf
End Sub
展开
 我来答
百度网友95cc616
2014-04-03 · TA获得超过250个赞
知道小有建树答主
回答量:448
采纳率:100%
帮助的人:269万
展开全部
服务端代码改成如下
Private Sub Command1_Click()
Me.Winsock1.SendData Trim(Text2.Text)
End Sub

Private Sub Command2_Click()
Text2.Text = ""
End Sub

Private Sub Command3_Click()
Winsock1.Close
End Sub

Private Sub Form_Load()
Winsock1.Bind 30000
Winsock1.Listen
End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Accept requestID
Me.Text1.Text = "与控制端连接成功"
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim mys As String
Winsock1.GetData mys
Me.Text1.Text = Me.Text1.Text & mys & vbCrLf
End Sub

客户端代码改成下面的
Private Sub Command1_Click()
Winsock1.RemoteHost = Trim(Me.Text1.Text) '远程计算机的名称或地址
Winsock1.RemotePort = Trim(Me.Text2.Text)
Winsock1.Close
Winsock1.Connect
Command1.Enabled = False

End Sub

Private Sub Command2_Click()
Winsock1.SendData Trim(Text4.Text)
End Sub

Private Sub Command3_Click()
Text4.Text = ""
End Sub

Private Sub Command4_Click()
Me.Winsock1.Close
Me.Command1.Enabled = True
End Sub

Private Sub Form_Load()
Text1.Text = "127.0.0.1"
Text2.Text = "30000"
Command4.Enabled = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
Winsock1.Close
End Sub

Private Sub Winsock1_Close()
Winsock1.Close
End Sub

Private Sub Winsock1_Connect()
Me.Text3.Text = "与被控端连接成功!" & vbCrLf
Winsock1.SendData Winsock1.LocalIP '返回本地机器的 IP 地址
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim mys As String
Winsock1.GetData mys
Me.Text3.Text = Me.Text3.Text & mys & vbCrLf
End Sub
试下吧
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2014-04-02
展开全部
比较复杂,建议一步一步删减代码检查
追问
肯定是不容易啊
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
IT消防员
2014-04-02 · 超过36用户采纳过TA的回答
知道小有建树答主
回答量:240
采纳率:50%
帮助的人:65.6万
展开全部
你都没截图说错误断点在哪里
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式