你好这是我编的一个聊天室程序连接成功时服务端提示运行时需要对象为什么。这是程序。服务器端。
Private Sub Command1_Click()
Dim MySendData As String
MySendData = txt_send.Text
Winsockserver.SendData MySendData
txt_send.Text = ""
End SubPrivate Sub Command2_Click()
End
End SubPrivate Sub Form_Load()
Winsockserver.Listen
End SubPrivate Sub Timer1_Timer()
Select Case Winsockserver.State
Case 0: Label1.Caption = "服务器关闭"
Case 2: Label1.Caption = "服务器侦听"
Case 7: Label1.Caption = "服务器已经连接"
End Select
End SubPrivate Sub Winsockserver_ConnectionRequest(ByVal requestID As Long)
'判断服务器不关闭时接受连接请求
If SockServer.State <> sckClosed Then SockServer.Close
SockServer.Accept requestID
End SubPrivate Sub Winsockserver_DataArrival(ByVal bytesTotal As Long)
Dim MyGetData As String
'得到数据
Winsockserver.GetData MyGetData
If MyGetData = "~quit~" Then
SockServer.Close
SockServer.Listen
End If
txt_get.Text = txt_get.Text & Chr(13) & Chr(10) & MyGetData
End Sub客户端
Private Sub Command1_Click()
Winsockclient.SendData Textsend.Text
End SubPrivate Sub Command2_Click()
Winsockclient.RemoteHost = Text2.Text
Winsockclient.RemotePort = 1001
Winsockclient.Connect
End SubPrivate Sub Form_Load()
Textsend.Visible = False
Textget.Visible = False
End SubPrivate Sub Timer1_Timer()
Select Case Winsockclient.State
Case 0: Label1.Caption = "客户端关闭"
Case 1: Label1.Caption = "客户端打开"
Case 7: Label1.Caption = "客户端已经连接"
End Select
End SubPrivate Sub Winsockclient_Connect()
Textsend.Visible = True
Textget.Visible = True
End SubPrivate Sub Winsockclient_DataArrival(ByVal bytesTotal As Long)
Dim tmpstr As String Winsockclient.GetData tmpstr Textget.Text = tmpstrEnd Sub
Private Sub Command1_Click()
Dim MySendData As String
MySendData = txt_send.Text
Winsockserver.SendData MySendData
txt_send.Text = ""
End SubPrivate Sub Command2_Click()
End
End SubPrivate Sub Form_Load()
Winsockserver.Listen
End SubPrivate Sub Timer1_Timer()
Select Case Winsockserver.State
Case 0: Label1.Caption = "服务器关闭"
Case 2: Label1.Caption = "服务器侦听"
Case 7: Label1.Caption = "服务器已经连接"
End Select
End SubPrivate Sub Winsockserver_ConnectionRequest(ByVal requestID As Long)
'判断服务器不关闭时接受连接请求
If SockServer.State <> sckClosed Then SockServer.Close
SockServer.Accept requestID
End SubPrivate Sub Winsockserver_DataArrival(ByVal bytesTotal As Long)
Dim MyGetData As String
'得到数据
Winsockserver.GetData MyGetData
If MyGetData = "~quit~" Then
SockServer.Close
SockServer.Listen
End If
txt_get.Text = txt_get.Text & Chr(13) & Chr(10) & MyGetData
End Sub客户端
Private Sub Command1_Click()
Winsockclient.SendData Textsend.Text
End SubPrivate Sub Command2_Click()
Winsockclient.RemoteHost = Text2.Text
Winsockclient.RemotePort = 1001
Winsockclient.Connect
End SubPrivate Sub Form_Load()
Textsend.Visible = False
Textget.Visible = False
End SubPrivate Sub Timer1_Timer()
Select Case Winsockclient.State
Case 0: Label1.Caption = "客户端关闭"
Case 1: Label1.Caption = "客户端打开"
Case 7: Label1.Caption = "客户端已经连接"
End Select
End SubPrivate Sub Winsockclient_Connect()
Textsend.Visible = True
Textget.Visible = True
End SubPrivate Sub Winsockclient_DataArrival(ByVal bytesTotal As Long)
Dim tmpstr As String Winsockclient.GetData tmpstr Textget.Text = tmpstrEnd Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货