Solved

treeview building

Posted on 1998-12-14
6
203 Views
Last Modified: 2010-05-03
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
Comment
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
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 7

Accepted Solution

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

Private Sub Form_Load()
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

by:ilanm
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

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

Private Sub Form_Load()
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:ilanm
ID: 1450072
Inteqam i still get the error msg of object not found.

0
 
LVL 7

Expert Comment

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

0
 
LVL 7

Expert Comment

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

try now.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question