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
Solved

treeview building

Posted on 1998-12-14
6
201 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
  • 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

765 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