dim nodex as node dim i as integer i=0 for each nodex in treeview1.nodes if nodex.Parent="" then i=i+1 endif nextmsgbox i
也可通过在建树时标识不同的关键字 如根结点以Root开头 子结点以Sub开头
dim iCount as integer dim tnode as node icount=0 with treeview1 for each tnode in .nodes. if tnodes(i).parent is nothing then icount=icount+1 endif next end withmsgbox "共有" & icount & "个根节点!"
dim i as integer
i=0
for each nodex in treeview1.nodes
if nodex.Parent="" then
i=i+1
endif
nextmsgbox i
dim tnode as node
icount=0
with treeview1
for each tnode in .nodes.
if tnodes(i).parent is nothing then
icount=icount+1
endif
next
end withmsgbox "共有" & icount & "个根节点!"