Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# treeview building

Posted on 1998-12-14
Medium Priority
206 Views
i am trying to build a stair tree. i have succeeded in building a root node and a few children with the treeview.nodes.add but for some reason when i try to build a two level tree of questions answers meaning:
q
---a
q
---a
q
---a
as it is writen in the help file, i get a debug msg. that the object is not found. can you write me an example that builds a tree like the example above.
thank you.
p.s i'm using vb6.
0
Question by:ilanm
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4
• 2

LVL 7

Accepted Solution

Inteqam earned 150 total points
ID: 1450069
insert a treeview in a form and paste the following:

Dim n As Node

Set n = Me.TreeView1.Nodes.Add(, , "root", "root")
Set n = Me.TreeView1.Nodes.Add("root", tvwChild, "q1", "q")
Set n = Me.TreeView1.Nodes.Add("root", tvwChild, "q2", "q")
Set n = Me.TreeView1.Nodes.Add("root", tvwChild, "q3", "q")
Set n = Me.TreeView1.Nodes.Add("q1", tvwChild, "a1", "a")
Set n = Me.TreeView1.Nodes.Add("q2", tvwChild, "a2", "a")
Set n = Me.TreeView1.Nodes.Add("q3", tvwChild, "a3", "a")

End Sub

0

Author Comment

ID: 1450070
thank you for your answer, but i meant a dynamic tree where there could be 100 question answers or 3.
0

LVL 7

Expert Comment

ID: 1450071
try this
insert a treeview in a form and paste the following:

Dim n As Node
Dim Count as integer
Dim strKeyq as String
Dim strKeta
Set n = Me.TreeView1.Nodes.Add(, , "root", "root")
' use a counter for the Q's
while there is more questions
count=count+1
strKeyq="q"+cstr(Count)
strKeya="a"+Cstr(Count)
Set n = Me.TreeView1.Nodes.Add("root", tvwChild, strkeyq, "q")
Set n = Me.TreeView1.Nodes.Add(strkeyq, tvwChild, strkeya, "a")
wend
End Sub

0

Author Comment

ID: 1450072

0

LVL 7

Expert Comment

ID: 1450073
it works will in my PC ,
where the error happens?

0

LVL 7

Expert Comment

ID: 1450074
mis spilled Dim strKeta
it must be Dim strKeya

try now.

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
###### Suggested Courses
Course of the Month10 days, 5 hours left to enroll