在VB6.0中如何判断treeview的一个结点是否存在Parment结点   , 如果不判断的话程序会报错的确良,  StrL = Trim(treview1.SelectedItem.Parent.Text) , 如何判断是否存在Parment结点  ,请大家帮帮忙 

解决方案 »

  1.   

    TreeView还没用过。
    Option ExplicitPrivate Sub Command1_Click()
    Dim StrL As String
    On Error GoTo errHandle
    StrL = TreeView1.SelectedItem.Parent.Text
    Exit Sub
    errHandle:
    Select Case Err.Number
      Case 91
        '未选中内容,节点不存在,进行错误处理
        '错误处理过程
    End Select
    End Sub
      

  2.   

    判断父节点是否为空:if not (TreeView1.SelectedItem.Parent is nothing) then
      StrL = TreeView1.SelectedItem.Parent.Text
    end if
      

  3.   

    VB中对于object变量是否为空就是用 is nothing判断的
      

  4.   

    一般用KEY值,防止有重复
    TreeView1.SelectedItem.Parent.Key