Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you want to improve a Control's functionality, how do you do it?
The code below is based on my hunch of how VBA works. Amazingly, it works. But is it legit? My UserForm has a TreeView. In Initialize(), I equivalence it to a New instance of my "ImprovedTreeView" class. Is that the best, most VBA-native way to do it? Even eliminating one step would improve things. My biggest confusion is: In a class module, how do you descend from another class? I want CImprovedTreeView to have all the behavior of TreeView, plus my stuff. I get around it now by implementing a property of CImprovedTreeView of the type (TreeView) I want to descend from. But that sure is kluge-a- delic: *** ‘CLASS MODULE CImprovedTreeView Option Explicit Private g_Tree As TreeView 'Sample property...which works fine! Public Property Get FirstNode() As Node 'Action: Return the topmost node of the tree. 'Note: I was going crazy, because I thought, doesn't .Nodes(1) give you that? Nein, Dummkopf! Dim N As Node 'Take any node, ascend to its root, then take the root's first sibling. With g_Tree If .Nodes.Count 0 Then Set N = .Nodes(1) While Not (N.Parent Is Nothing) Set N = N.Parent Wend Set FirstNode = N.FirstSibling End If End With End Property Public Property Set Tree(TV As TreeView) Set g_Tree = TV End Property ‘MODULE UserForm1 ‘TreeView1 is on this form. Option Explicit Private ImprovedTreeView as CImprovedTreeView Private Sub UserForm_Initialize() ‘Note: Why do I have to get involved with naming two classes (TreeView and CTreeView)? Can I dispense with one? Set ImprovedTreeView = New CImprovedTreeView Set ImprovedTreeView.Tree = TreeView1 End Sub Private Sub DoSomething Dim N as Node Set N = ImprovedTreeView.FirstNode ‘etc. End Sub *** Thanks. *** |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How best to integrate/implement this? | Excel Programming | |||
WNetGetUniversalName - how to implement in VBA? | Excel Programming | |||
how to implement xbrl | Excel Discussion (Misc queries) | |||
Do anyone know how to implement the function? | Excel Programming | |||
How to implement an iRtdServer? | Excel Programming |