private sub cmdSendDatas()
clientSock.RemoteHost = "localhost" '远程主机名
clientSock.RemotePort = 1011 '网络端口
clientSock.Connect '发出连接命令 '发送数据
clientSock.SendData SendData
End Sub显示错误:
Run-time error '40006'
Wrong protocol or connection state for the requested transaction or request
如果将clientSock.SendData SendData放到一按钮中,用按钮执行,则正确
Private Sub cmdSend_Click()
clientSock.SendData SendData
End Sub
if clientSock.state > 7 then msgbox "Error, cannot connect to server."
doevents
loop '发送数据
clientSock.SendData SendData
虽然你是调用了connect,但是winsock还没有连上去,所以说“错误的协议或连接状态”