一下标注。红色全部为不懂不会的,绿色为标记信息 Main code Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public ServerPort As String 连接端口号 Public SockInt As Integer '当前有多少个连接开始工作 Public SockData As Variant '当前连接数组 (Variant 数据类型来替换任何数据类型) Public SockUser As Variant '当前连接的用户ID Private Sub ColBut1_Click() If MiniNumber.Text = "" Then text 名称为minninumber EchoLog ("请在输入框中输入要关闭的灯具缩微编号") End If If SockInt <= 0 Then EchoLog ("尚未任何客户端连接,无法关闭灯具") 文本框的显示内容 End If Dim cmdStr As String cmdStr = "78000000000001020199990000ABCD17" Call mySocket_Send(0, cmdStr) 函数或称为过程 End Sub Private Sub Form_Load() Me.Caption = GetINI("SoftName", "system.ini") 不太懂修改配置文件吗 ServerPort = CInt(GetINI("Prot", "system.ini")) SendUser.Clear SendUser.AddItem "全部用户", 0 SendUser.ListIndex = 0 EchoLog ("系统成功启动.....") End Sub 窗体加载时将“全部用户”添加到senduser 控 件中,,并被默认选择 判断是否与客户端连接 并调用 mycocket_send 过称 Private Sub But_Start_Click() Dim ButName As String ButName = But_Start.Caption If ButName = "开始监听" Then Call StartWinSock 调用监听函数 Else Call EndWinSock 关闭监听函数 End If End Sub Private Sub Form_Unload(Cancel As Integer) If MsgBox(" 你确定要退出系统么?", vbOKCancel, " 关闭确认") = vbOK Then Cancel = 0 Else Cancel = 1 End If End Sub Private Sub SendText_KeyPress(KeyAscii As Integer) If KeyAscii = 10 Then Call SendBut_Click KeyAscii = 0 End If End Sub Private Sub LineShow_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub '打开监听服务 Public Sub StartWinSock() 为什么不写为当单击它 时 候 启 动 Startwinsock 而要根据butname 的值来判断呢 当选了 ok 时 变量 cancel 为0 否则为1 什么时候用 什么时候用 But_Start.Caption = "暂停监听" Cal...