如标题,我的部分代码如下:            If Client_Controls_Loaded(Index) = True Then
                Client_Controls_Loaded(Index) = False
                Unload WskClient(Index)
            End If
            Load WskClient(Index)
            Client_Controls_Loaded(Index) = True我用了Client_Controls_Loaded(Index)变量标记Winsock控件是否加载,能否直接通过控件本身就能判断控件是否加载?

解决方案 »

  1.   

    On Error Resume Next
      

  2.   


    没写完就出去了:(Private Sub Command1_Click()
        On Error Resume Next
            Load Winsock1(1)
            If Err.Number = 360 Then MsgBox "对象已存在", , "错误"
        On Error GoTo 0
    End Sub注意INDEX
    ^_^
      

  3.   

    If Not Winsock1(1) Is Nothing then
       '已加载
    End If
      

  4.   

    Option Explicit楼上的:如下
    我在没有执行Command1_Click()之前执行了Command2_Click(),但得到的消息却是“已加载”,这是为何呢?
    Private Sub Command1_Click()
        Load Winsock1(1)
    End SubPrivate Sub Command2_Click()
        If Not Me.Winsock1(1) Is Nothing Then
            MsgBox "已加载"
        Else
            MsgBox "没有加载"
        End If
    End SubPrivate Sub Winsock1_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)End Sub
      

  5.   


    Private Sub Command2_Click()
        If Not Me.Winsock1(1) Is Nothing Then
            MsgBox "已加载"
        Else
            Load Winsock1(1)
        End If
    End Sub