Selection Set two different string filter

Selection Set two different string filter

grobnik
Collaborator Collaborator
648 Views
3 Replies
Message 1 of 4

Selection Set two different string filter

grobnik
Collaborator
Collaborator

Hi to everybody.

Please could you help me with Selectionset Functionality Filter.

I would like to search two different string with selection set, in case adding wild cards.

The main issue concern the LOGIC OPERATOR "OR" to be used or not.

Thank you

 

    Set MySelection = ThisDrawing.SelectionSets.Add("PP1")

    filterType(0) = -4
    filterData(0) = "<OR"
    
    filterType(1) = 0
    filterData(1) = "Text"
    
    filterType(2) = 2
    filterData(2) = "STRING 1"
     
    filterType(3) = 0
    filterData(3) = "Text"
    
    filterType(4) = 2
    filterData(4) = "STRING 2"
    
    filterType(5) = -4
    filterData(5) = "OR>"
MySelection.Select acSelectionSetAll, , , filterType, filterData

 

 

0 Likes
Accepted solutions (1)
649 Views
3 Replies
Replies (3)
Message 2 of 4

Ed__Jobe
Mentor
Mentor
Accepted solution

Is it not working? You haven't really said what the problem is.

 

You can use wildcards. Just precede the wildcard with a backwards apostrophe, e.g. "`*test". It's key is usually to the left of 1.

 

Also, I wrote this sub to make it easier to create complex filters.

 

 

 


Public Sub BuildFilter(typeArray As Variant, dataArray As Variant, ParamArray gCodes())

    'Purpose
    'Fills a pair of variants with arrays for use as a selection set filter
    '
    'Arguments
    'Two variants (not variant arrays) and an unlimited number of group code / value pairs
    '
    'Example
    'BuildFilter fType, fData, 0, "LINE", 7, "WALLS"

    Dim fType() As Integer, fData()
    Dim index As Long, i As Long
    
    index = LBound(gCodes) - 1
        
    For i = LBound(gCodes) To UBound(gCodes) Step 2
        index = index + 1
        ReDim Preserve fType(0 To index)
        ReDim Preserve fData(0 To index)
        fType(index) = CInt(gCodes(i))
        fData(index) = gCodes(i + 1)
    Next
    typeArray = fType: dataArray = fData

End Sub

Sub test1()
  Dim fType As Variant, fData As Variant
  BuildFilter fType, fData, -4, "<OR", _
                               0, "TEXT", 2, "STRING 1" _
                               0, "TEXT", 2, "STRING 2" _
                            -4, "OR>"
End Sub

Sub test2()
  Dim fType As Variant, fData As Variant
  BuildFilter fType, fData, 0, "TEXT", 2, "STRING `?"
End Sub

 

 

 

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 4

grobnik
Collaborator
Collaborator

@Ed__Jobe Thank you for your code but seems that several string will be found and not only STRING 1 or STRING 2.

I'm using wildcards selecting all STRING 1 that begins with "STR*" or "STRI*".

Thank you

0 Likes
Message 4 of 4

Ed__Jobe
Mentor
Mentor
In test1, Only "STRING 1" or "STRING 2" will be matched since no wildcards are used.

In test2, "STRING ?" matches a single character.e.g. "STRING A" or "STRING 9". "STRING #" matches a single digit. e.g. 0-9, but not 10-99.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes