Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Collection Objects/Classes?

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
0
0
US
Ok here is what I am trying to do.<br>
I want to store a collection of &quot;Shapes&quot; so to speak<br>
this is somewhat of the visual representation, I'm looking at it as if they were 3 Collections, 2 types under 1.<br>
<br>
Shapes<br>
¦--Name<br>
¦--Sic2<br>
¦ ¦--Sic4<br>
¦ ¦ ¦--Siccode<br>
¦ ¦ ¦--Description<br>
¦ ¦ ¦--Expanded<br>
¦ ¦ ¦--Plotted<br>
¦ ¦ ¦--Total<br>
¦ ¦--Description<br>
¦ ¦--Expanded<br>
¦ ¦--Plotted<br>
¦ ¦--Total<br>
¦--Sic4<br>
¦--Siccode<br>
¦--Description<br>
¦--Expanded<br>
¦--Plotted<br>
¦--Total<br>
Shape2<br>
¦--... <br>
a Shap has its own info, then has a list of Sic2 or Sic4<br>
Sic2 is a broad catagory, like 2 digit 2500<br>
Sic4 is more specific like 4 digits 2538<br>
which has no more collections under it<br>
a Sic4 will have its own info, and stops there<br>
a Sic2 will have its broad description, then all the sic4 that apply to it.<br>
<br>
Now the only thing I want to know, is how to create Collections, then manage them like Add, Delete, that kind of thing.<br>
<i>I checked MSDN on a generic collectino type that is only a single collection with nothing under it, using a class as a root for that collection.</i> <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
I have made 4 Class Module files in order to set up how the Collections might be, I still however trying to figure out how I might be able to do multiple collections under one another<br>
<br>
SicCodes (SicCodes.cls)<br>
-----------------------------<br>
Public Shapes As New Collection<br>
<br>
Shapes (Shapes.cls)<br>
-----------------------------<br>
Public Name As String<br>
Public Sic2 As New Collection<br>
Public Sic4 As New Collection<br>
<br>
Sic2 (Sic2.cls)<br>
-----------------------------<br>
Public SicCode As String<br>
Public SicDesc As String<br>
Public Expanded As Boolean<br>
Public Plotted As Boolean<br>
Public total As Long<br>
Public Sic4 As New Collection<br>
<br>
Sic4 (Sic4.cls)<br>
-----------------------------<br>
Public SicCode As String<br>
Public SicDesc As String<br>
Public Plotted As Boolean<br>
Public total As Long<br>
<br>
<br>
<i> As you can see Sic4 is the only collection that will not have multiples underneath it, and cannot be expanded</i><br>
<br>
Any sugestions? <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Oh one of the other things that I wanted to make note of, this &quot;project&quot; I want to keep into a class or Classes of its own , so that it does not have to be on a form or anything else, that way I can make methods , to add, delete, clear, whichever, and when I am ready to move it into an ActiveX control, can just use those methods/functions to get, and set data. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
With the same thing as above, this code i inserted into the SicCode.cls , which basically builds the Shape<br>
<br>
Public Sub SicShape(Name As String, ShapeType As String, SIC As String, Desc As String, employers As String)<br>
Dim NewSh As New Shapes<br>
Dim NewS2 As New Sic2<br>
Dim NewS4 As New Sic4<br>
Dim idx As Integer<br>
Dim sicid As String<br>
Dim objSicStuff As Object<br>
Set objSicStuff = CreateObject(&quot;wiDataAccess.Dataconnection&quot;)<br>
<br>
objSicStuff.ConnectionString = &quot;dsn=siccode;uid=sa;pwd;&quot;<br>
objSicStuff.Connect<br>
<br>
If Desc = &quot;&quot; Then<br>
Desc = objSicStuff.GetSicTitle(SIC)<br>
End If<br>
<br>
'Dont know if this next line will work<br>
If Shapes.Item(Name) Then<br>
NewSh = Shapes.Item(Name)<br>
Else<br>
NewSh.Name = Name<br>
End If<br>
<br>
sicid = Trim(SIC)<br>
If Len(sicid) = 2 Then<br>
NewS2.SicDesc = Desc<br>
NewS2.SicCode = sicid<br>
NewS2.total = 0<br>
<br>
Set rs = objSicStuff.GetSic4Titles(sicid)<br>
Do While Not rs.EOF<br>
NewS4.SicCode = rs!SicCode<br>
NewS4.SicDesc = rs!sictitle<br>
NewS2.Sic4.Add NewS4<br>
NewS2.total = NewS2.total + 1<br>
rs.movenext<br>
Loop<br>
NewSh.Sic2.Add NewS2<br>
Else<br>
NewS4.SicCode = sicid<br>
NewS4.SicDesc = Desc<br>
NewSh.Sic4.Add NewS4<br>
End If<br>
Shapes.Add NewSh<br>
End Sub<br>
<br>
Seems lenghty might be able to shorten it, the main thing now is to make it check to see if a Shape item of the same name already exist and if so just add on a new Sic2 or Sic4.<br>
Then to be able to figure out howto Get , Edit, Delete parts of it. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top