关于vb中40006错误
发布网友
发布时间:2022-04-20 09:20
我来回答
共3个回答
热心网友
时间:2023-07-02 06:48
服务端代码改成如下
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
试下吧
热心网友
时间:2023-07-02 06:49
比较复杂,建议一步一步删减代码检查追问肯定是不容易啊
热心网友
时间:2023-07-02 06:49
你都没截图说错误断点在哪里