Message 1 of 7
Enumerating Occurrences

Not applicable
11-14-2005
10:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm using the following function to enumerate the occurrence collection:
Public Function FindOccurrence(OccurCollection As ComponentOccurrences, Name As String) As ComponentOccurrence
Dim Occ As ComponentOccurrence
Set FindOccurrence = Nothing
On Error Resume Next
For Each Occ In OccurCollection
Debug.Print Name,
Debug.Print Occ.Name,
If InStr(UCase(Occ.Name), UCase(Name)) 0 Then
If Err.Number = 0 Then
Debug.Print "Found"
Set FindOccurrence = Occ
Exit Function
Else
Debug.Print Err.Description
Err.Clear
End If
Else
Debug.Print "Found"
End If
Next Occ
SkipOnError:
Set FindOccurrence = Nothing
End Function
When I do so, I get this output:
Slide_SBPocketTop Slide:1 Found
Slide_SBPocketTop SidePlate:1 Found
Slide_SBPocketTop SidePlate:2 Found
Slide_SBPocketTop SlideTrapezoid:1 Found
Slide_SBPocketTop Slide_SBPocketSide:1 Found
Slide_SBPocketTop Slide_SBPocketSide:2 Found
Slide_SBPocketTop Method 'Name' of object '_IRxComponentOccurrence' failed
Slide_SBPocketTop Method 'Name' of object '_IRxComponentOccurrence' failed
Slide_SBPocketTop Coupling Nut:1 Found
Slide_SBPocketTop Coupling Nut:2 Found
Slide_SBPocketTop JamNut:1 Found
Slide_SBPocketTop JamNut:2 Found
Slide_SBPocketTop JamBolt:1 Found
Slide_SBPocketTop JamBolt:2 Found
Slide_SBPocketTop Method 'Name' of object '_IRxComponentOccurrence' failed
Slide_SBPocketTop VerticalPlate_Angle:1 Found
Slide_SBPocketTop SlideStiffenerAngle:1 Found
Slide_SBPocketTop Method 'Name' of object '_IRxComponentOccurrence' failed
Slide_SBPocketTop SlideStiffenerAngle:2 Found
Slide_SBPocketTop SlideStiffenerAngle:3 Found
Notice that the 'Name' method fails fairly frequently. Can anyone enlighten me as to why this might be the case? It seems like a bug to me...
Thanks,
Jon Brierley
Public Function FindOccurrence(OccurCollection As ComponentOccurrences, Name As String) As ComponentOccurrence
Dim Occ As ComponentOccurrence
Set FindOccurrence = Nothing
On Error Resume Next
For Each Occ In OccurCollection
Debug.Print Name,
Debug.Print Occ.Name,
If InStr(UCase(Occ.Name), UCase(Name)) 0 Then
If Err.Number = 0 Then
Debug.Print "Found"
Set FindOccurrence = Occ
Exit Function
Else
Debug.Print Err.Description
Err.Clear
End If
Else
Debug.Print "Found"
End If
Next Occ
SkipOnError:
Set FindOccurrence = Nothing
End Function
When I do so, I get this output:
Slide_SBPocketTop Slide:1 Found
Slide_SBPocketTop SidePlate:1 Found
Slide_SBPocketTop SidePlate:2 Found
Slide_SBPocketTop SlideTrapezoid:1 Found
Slide_SBPocketTop Slide_SBPocketSide:1 Found
Slide_SBPocketTop Slide_SBPocketSide:2 Found
Slide_SBPocketTop Method 'Name' of object '_IRxComponentOccurrence' failed
Slide_SBPocketTop Method 'Name' of object '_IRxComponentOccurrence' failed
Slide_SBPocketTop Coupling Nut:1 Found
Slide_SBPocketTop Coupling Nut:2 Found
Slide_SBPocketTop JamNut:1 Found
Slide_SBPocketTop JamNut:2 Found
Slide_SBPocketTop JamBolt:1 Found
Slide_SBPocketTop JamBolt:2 Found
Slide_SBPocketTop Method 'Name' of object '_IRxComponentOccurrence' failed
Slide_SBPocketTop VerticalPlate_Angle:1 Found
Slide_SBPocketTop SlideStiffenerAngle:1 Found
Slide_SBPocketTop Method 'Name' of object '_IRxComponentOccurrence' failed
Slide_SBPocketTop SlideStiffenerAngle:2 Found
Slide_SBPocketTop SlideStiffenerAngle:3 Found
Notice that the 'Name' method fails fairly frequently. Can anyone enlighten me as to why this might be the case? It seems like a bug to me...
Thanks,
Jon Brierley