Solved

treeview building

Posted on 1998-12-14
6
199 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pull multiple cvs files into one access table 28 64
Sending a email via excel using vba 6 71
Hide vba in gp 7 82
Recommendation vb6 to vb.net or others 14 109
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now