代码之家  ›  专栏  ›  技术社区  ›  Chris Tonkinson

不理解“需要对象”错误

  •  2
  • Chris Tonkinson  · 技术社区  · 14 年前

    我有以下ASP经典函数:

    function get_children(n)
      dim local_array
      dim parent
      dim path
      if n.hasChildNodes() then
        for each child in n.childNodes
          local_array = array_merge(local_array, get_children(child))
        next
      else
        set parent = n.parentNode
        while isobject(parent)
          path = parent.nodeName & "/" & path
          set parent = parent.parentNode
        wend
        path = path & "/" & get_attr(n, "file")
        set_attr n, "path", path
        local_array = Array(0)
        set local_array(0) = n
      end if
      get_children = local_array
    end function
    

    在一个XML节点上运行(来自microsoft.xmldom对象),我得到了这个错误 Object required: 'parent' 在线

    path = parent.nodeName & "/" & path
    

    我不明白为什么。我在检查 isobject . 有人能解释运行时在抱怨什么吗?为什么?

    2 回复  |  直到 14 年前
        1
  •  2
  •   Guffa    14 年前

    Nothing IsObject(Nothing) True

    while not (parent is Nothing)
    
        2
  •  0
  •   Andrew Bezzub    14 年前

    IsObject IsEmpty() IsNull() Is Nothing

    If Not (myObject Is Nothing)