Hard to know how to classify this question so apologies for the
cross-post.
I am writing an application using VBA Retail 6.4.9972 over VB 6.3
inside AutoCAD 2002 (Wait! Don't abandon this question VB programmers
- you really don't need to know anything about AutoCAD in order to
help). It's a fairly sizeable application (10,000+ lines) and is
working quite well but this thing has had me pulling my hair out since
yesterday.
I am using a Dictionary to store information about roof struts but I've
found that modifying the Item for a particular key modifies not only
the intended item, but also another (seemingly unrelated) item!! It's
true! I've stepped through line by line and can see in the Watch
window that they *both* change when the one assignment line is
executed. Now the data structure is not straightforward and it may be
related to that but I've tried various modifications on the theme and
the same problem keeps happening.
Here's the relevant code:
In a class module named Strut2DClass
------------------------------------
Public MaxPosition
Public MinPosition
Public MinHalfSpread As Double
Public ActualPosition
Public ActualHalfSpread As Double
Public LineHandle As String
Public StrutLength As Long
Public ParentDetails As New Dictionary
In the standard AutoCAD module named ThisDrawing
------------------------------------------------
Private Sub Strutting2DTree(Strut2DDict As Dictionary)
Dim Strut2D As New Strut2DClass
Dim CurrentBranch As String
Dim StrutLength As Double
.
.
.
Strut2DDict.Add CurrentBranch, Strut2D
.
.
.
Strut2DDict(CurrentBranch).StrutLength = StrutLength
Struts may be Vertical or Fan struts and the Dictionary key
CurrentBranch contains the series of struts at the current level, eg
"FF", "FVFV". When the last line of code above is executed for
CurrentBranch "FFF", the .StrutLength is changed for both "FFF" *and*
"FFV" (as witnessed in the Watch window). How can this be??
The other point that *may* be relevant (although I don't see how) is
that this procedure Strutting2DTree can recursively call itself in
certain circumstances (hence the references to "tree" and "branch").
I would very much appreciate any suggestions.
Thanks
Wayne Ivory
Senior Analyst Programmer
Electronic Business Development
Wespine Industries Pty Ltd