Private Sub Command3_Click()
Dim i%
'检查状态,若不是关闭,则执行关闭
If Winsock1.State <> 0 Then Winsock1.Close
'设置远程的地址及通信端口号码
Winsock1.RemoteHost = txtIP.Text
Winsock1.RemotePort = txtPort.Text
Winsock1.Connect '执行连接
TimeDelay 100
'循环等待连接成功
Do
DoEvents
Loop Until Winsock1.State = sckConnected
Me.Caption = "已连接"
'以下将传输数据的Check Box及按钮致能
For i = 0 To 7
ctrlout(i).Enabled = True
Next i
Command1.Enabled = True
End Sub