Author Topic: Got Arrays?  (Read 11995 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
Re: Got Arrays?
« Reply #30 on: May 07, 2008, 11:44:01 AM »
You're not reassigning "dwg" at any point in the loop - therefore dwg still refers to the last object you pushed into the collection (assuming, of course, you're running it in the button's sub)

I think I've got it.

Code: [Select]
    Dim x As Integer
    Dim y As Integer
   
    For x = 1 To colDwg.Count
        Set dwg = colDwg.Item(x)
        Debug.Print dwg.fileName
        For y = 1 To dwg.Count
            Debug.Print dwg.Item(y)
        Next y
    Next x

Which will give me...

Quote
0004000-T-NOT.dwg
T-000
0004000-T-COMM-1.dwg
TC-101
TC-102
0004000-T-SECY-1.dwg
TS-101
TS-102
0004000-T-SITE.dwg
TS-000
0004000-T-PART.dwg
TC-201
TC-202
0004000-T-RISR.dwg
TC-301
TC-302
0004000-T-DETL.dwg
TC-401
TC-402
TC-403
TC-404

Which is what I wanted to do from the beginning.



Man, I wasn't even CLOSE with what I was trying to do originally!!  I had started with creating a collection and then trying to add arrays to each item which only got me more confused.

I'm going to continue to disect this stuff (especially 'dwgInfoExists' and 'dwgInfoIndex') to get a better understanding of what's going on so I won't have to ask/beg/plead for help with something like this in the future.  I owe you one.  Thanks.

Tuoni

  • Gator
  • Posts: 3032
  • I do stuff, and things!
Re: Got Arrays?
« Reply #31 on: May 07, 2008, 11:50:07 AM »
You're not reassigning "dwg" at any point in the loop - therefore dwg still refers to the last object you pushed into the collection (assuming, of course, you're running it in the button's sub)

I think I've got it.

Code: [Select]
    Dim x As Integer
    Dim y As Integer
   
    For x = 1 To colDwg.Count
        Set dwg = colDwg.Item(x)
        Debug.Print dwg.fileName
        For y = 1 To dwg.Count
            Debug.Print dwg.Item(y)
        Next y
    Next x

Which will give me...

Quote
0004000-T-NOT.dwg
T-000
0004000-T-COMM-1.dwg
TC-101
TC-102
0004000-T-SECY-1.dwg
TS-101
TS-102
0004000-T-SITE.dwg
TS-000
0004000-T-PART.dwg
TC-201
TC-202
0004000-T-RISR.dwg
TC-301
TC-302
0004000-T-DETL.dwg
TC-401
TC-402
TC-403
TC-404

Which is what I wanted to do from the beginning.



Man, I wasn't even CLOSE with what I was trying to do originally!!  I had started with creating a collection and then trying to add arrays to each item which only got me more confused.

I'm going to continue to disect this stuff (especially 'dwgInfoExists' and 'dwgInfoIndex') to get a better understanding of what's going on so I won't have to ask/beg/plead for help with something like this in the future.  I owe you one.  Thanks.
Not a problem!  Glad it works - the code I gave you could probably do with a clean up or there may be a more efficient way of doing what I'm doing or something (for instance, you could combine 'dwgInfoExists' and 'dwgInfoIndex' so that it returns just the index, or -1 if it's not in there, meaning you only iterate once)... but it works :)  I'm glad it's what you were looking for, sorry it took me so long to help you out!