Run-time disabling or filtering options in a popupmenu

Build 1501 on 14/Nov/2017  This topic last edited on: 19/Apr/2016, at 10:58

Filtering options in a popup menu

Assuming the alibobjs is a IdName list, containing names and ids of the library objects, and from which you are population the amenu string vector, the following code disables the names that does not satisfy the criteria:

    For Each idn As IdName In alibobjs

      If idn.Name.Contains("+"Or idn.Name.Contains("="Then

        Dim pPlus = InStr(idn.Name, "+")

        Dim pEQ = InStr(idn.Name, "=")

        If pPlus > 0 Then

          Dim mCol = CInt(Mid(idn.Name, pPlus - 1, 1))

          If nCol >= mCol Then

            amenu(i) = idn.Name

            i += 1

          End If

        ElseIf pEQ > 0 Then

          Dim mCol = CInt(Mid(idn.Name, pEQ - 1, 1))

          If nCol = mCol Then

            amenu(i) = idn.Name

            i += 1

          End If

        Else

          amenu(i) = idn.Name

          i += 1

        End If

      Else

        amenu(i) = idn.Name

        i += 1

      End If

    Next

Disabling options in a popup menu

Assuming the alibobjs is a IdName list, containing names and ids of the library objects, and from which you are population the amenu string vector, the following code filters the names to only ones that satisfy the criteria:

    For Each idn As IdName In alibobjs

      If idn.Name.Contains("+"Or idn.Name.Contains("="Then

        Dim pPlus = InStr(idn.Name, "+")

        Dim pEQ = InStr(idn.Name, "=")

        If pPlus > 0 Then

          Dim mCol = CInt(Mid(idn.Name, pPlus - 1, 1))

          If nCol >= mCol Then

            amenu(i) = idn.Name

          Else

            amenu(i) = "*" & idn.Name

          End If

        ElseIf pEQ > 0 Then

          Dim mCol = CInt(Mid(idn.Name, pEQ - 1, 1))

          If nCol = mCol Then

            amenu(i) = idn.Name

          Else

            amenu(i) = "*" & idn.Name

          End If

        Else

          amenu(i) = idn.Name

        End If

      Else

        amenu(i) = idn.Name

      End If

      i += 1

    Next