我正在尝试使用以下代码处理Winsock_Connect事件(实际上我需要在Excel宏中使用它):
Dim Winsock1 As Winsock 'Object type definition Sub Init() Set Winsock1 = CreateObject("MSWinsock.Winsock") 'Object initialization Winsock1.RemoteHost = "MyHost" Winsock1.RemotePort = "22" Winsock1.Connect Do While (Winsock1.State <> sckConnected) Sleep 200 Loop End Sub 'Callback handler Private Sub Winsock1_Connect() MsgBox "Winsock1::Connect" End Sub
但它永远不会进入Winsock1_Connect子程序,尽管Winsock1.State是"已连接".我想使用标准MS库,因为我的PC上没有管理权限,我无法注册一些自定义库.任何人都可以告诉我,我哪里错了?