当重新定义一个自定义动态数组时碰到这个错误:
ReDim Preserve m_tGroupedCollum(1 To m_lGroupedHeaderCount) As tGroupCollum
 或者                     
Erase m_tGroupedCollum你们有碰到过这个错误吗?怎么解决的?
MSDN上有一些这类问题的解决方法,好像说的不全面。
Run-time error 10
This array is fixed or temporarily locked
                http://support.microsoft.com/default.aspx?scid=kb;en-us;187553
http://support.microsoft.com/kb/176049/EN-US/            http://msdn2.microsoft.com/en-US/library/0d8t4e00(VS.80).aspx               http://microsoftluder.dk/resources/VBScript.5.6/html/vserrarrayfixedortemporarilylocked.htm
http://support.microsoft.com/kb/176049/pt-br

解决方案 »

  1.   

    见过一帖:
    http://community.csdn.net/Expert/TopicView3.asp?id=5595703
      

  2.   

    自定义的结构体:
    Private Type tGroupCollum
        lColumn                                                 As Long
        lOrigCollumSize                                         As Long
        lOrigCollumOrder                                        As Long
        tR                                                      As RECT
    End Type
      

  3.   


    这样呢:
    ReDim Preserve m_tGroupedCollum( m_lGroupedHeaderCount-1) As tGroupCollum
    从0开始,不用从1开始
      

  4.   

    情况一:
    With m_tGroupedCollum(i) <-自动对数组进行的锁定
      erase m_tGroupedCollum <-出错
      redim redim m_tGroupedCollum <-出错
    End With <-自动对数组解锁情况二:
    f m_tGroupedCollum(i) <-调用函数期间自动对数组进行锁定sub f(t as tgroupcollum)
      erase m_tGroupedCollum <-出错
      redim redim m_tGroupedCollum <-出错
    end sub
      

  5.   

    Tiger_Zhao(VB老鸟) :
    没有用With.这个是VB6的bugs.SP6好像还没有补丁。
    加On Error Resume Next去忽略这个报错。
      

  6.   

    你给的第一个链接是说在 With 语句对数组加锁后用了跳转语句没有执行 End With 处的解锁操作,这是 VB 编译器的 Bug。如果没有用到 With,请将代码贴出来。
      

  7.   

    你给的第一个链接是说在 With 语句对数组加锁后用了跳转语句没有执行 End With 处的解锁操作,这是 VB 编译器的 Bug。这个链接不是我的Posting.
    我是这样用的:m_iGroupedHeaderCount = m_lGroupedHeaderCount - 1
    If m_iGroupedHeaderCount > 0 Then
                    'On Error Resume Next ’ignore VB Runtime Error 10
                    'Run-time error 10
                    'This array is fixed or temporarily locked
                    'http://support.microsoft.com/default.aspx?scid=kb;en-us;187553
                    'http://support.microsoft.com/kb/176049/EN-US/
                    'http://msdn2.microsoft.com/en-US/library/0d8t4e00(VS.80).aspx
                    'http://microsoftluder.dk/resources/VBScript.5.6/html/vserrarrayfixedortemporarilylocked.htm
                    'http://support.microsoft.com/kb/176049/pt-br
                    ReDim Preserve m_tGroupedCollum(1 To m_iGroupedHeaderCount) As tGroupCollum
                Else
                    'On Error Resume Next  ’ignore VB Runtime Error 10
                    Erase m_tGroupedCollum
                End If
      

  8.   

    m_tGroupedCollum 如何声明?
    所有用到 m_tGroupedCollum 的代码请贴出来
      

  9.   

    Private m_tGroupedCollum() As tGroupCollum项目很大,不可能贴出。声明在Class级。
      

  10.   

    仔细检查代码,总有地方是对 m_tGroupedCollum 的数组进行访问而自动进行了锁定。简单测试无错:
    '== Class1.cls ==
    Option ExplicitPrivate Type tGroupCollum
        lColumn                                                 As Long
        lOrigCollumSize                                         As Long
        lOrigCollumOrder                                        As Long
        tR                                                      As RECT
    End TypePrivate m_tGroupedCollum() As tGroupCollum
    Private m_iGroupedHeaderCount As LongProperty Get Count() As Long
        Count = m_iGroupedHeaderCount
    End PropertySub Remove()
        'm_iGroupedHeaderCount = m_lGroupedHeaderCount - 1 '变量 m_lGroupedHeaderCount 是否拼错
        m_iGroupedHeaderCount = m_iGroupedHeaderCount - 1
        If m_iGroupedHeaderCount > 0 Then
            ReDim Preserve m_tGroupedCollum(1 To m_iGroupedHeaderCount) As tGroupCollum
        Else
            Erase m_tGroupedCollum
        End If
    End SubSub Add()
        m_iGroupedHeaderCount = m_iGroupedHeaderCount + 1
        ReDim Preserve m_tGroupedCollum(1 To m_iGroupedHeaderCount)
    End Sub'== Module1.bas ==
    Option ExplicitPublic Sub Main()
        Dim c As New Class1
                    Debug.Print c.Count
        c.Add:      Debug.Print c.Count
        c.Add:      Debug.Print c.Count
        c.Remove:   Debug.Print c.Count
        c.Remove:   Debug.Print c.Count
    End Sub
      

  11.   

    谢谢你的参与。这个是VB6的已知bugs.SP6好像还没有补丁。目前暂时加On Error Resume Next去忽略这个报错。你仔细阅读我上面提供的Microsoft MSDN的链接。
      

  12.   

    http://support.microsoft.com/default.aspx?scid=kb;en-us;187553
      这个是 Bug,但是用了 Withhttp://support.microsoft.com/kb/176049/EN-US/            http://msdn2.microsoft.com/en-US/library/0d8t4e00(VS.80).aspx               http://microsoftluder.dk/resources/VBScript.5.6/html/vserrarrayfixedortemporarilylocked.htm
    http://support.microsoft.com/kb/176049/pt-br
      这些是同一个问题,已经 Fix,我 VB+SP6 已经没有该错误了。我还是认为有地方引发了加锁,建议监视 SAFEARRAY.cLocks 的变化,《高级 Visual Basic 编程》有相关介绍。
      

  13.   

    对,查高级 Visual Basic 编程
    安全数组
      

  14.   

    高级Visual Basic编程?very good book!
      

  15.   

     要看你数组是如何声明的,如果声明为动态的(就是不指定数组维数)才能用redim,否则会出现这种错误