Private Sub Command1_Click() Dim n As Node Set n = TreeView1.SelectedItem Dim level As Long level = 0 Do Until n Is Nothing Set n = n.Parent level = level + 1 Loop If level = 0 Then MsgBox "選択されていません" Else MsgBox Format(level, "第0階層にいます") End If End Sub