SetCodeFilters

Replaces the Filter with pairs for source code files.

Syntax: object.SetCodeFilters

object
required An object expression that evaluates to a cDialog.

Remarks

SetCodeFilters calls ClearFilter, so any earlier filter is lost, and then AddFilter for each pair:

Description Pattern
Basic Files (*.bas;*.vba) *.bas;*.vba
C/C++ Files (*.c;*.cpp;*.h;*.hpp) *.c;*.cpp;*.h;*.hpp
C# Files (*.cs) *.cs
Java Files (*.java) *.java
Python Files (*.py) *.py
JavaScript Files (*.js) *.js
HTML Files (*.html;*.htm) *.html;*.htm
XML Files (*.xml) *.xml
All Files (*.*) *.*

The descriptions are fixed English text. To show other text, build the filter with AddFilter. The first pair, Basic Files, is the one that the dialog selects when it opens. A call of AddFilter after SetCodeFilters appends a pair after All Files.

Example

Dim dlg As New cDialog
Dim parts() As String
Dim pairCount As Long

dlg.SetCodeFilters
parts = Split(dlg.Filter, "|")
pairCount = (UBound(parts) + 1) \ 2
Debug.Print pairCount   ' 9
Debug.Print parts(0)    ' Basic Files (*.bas;*.vba)
Debug.Print parts(1)    ' *.bas;*.vba

This example appends a pair for twinBASIC source files to the list.

Dim dlg As New cDialog
Dim parts() As String

dlg.SetCodeFilters
dlg.AddFilter "twinBASIC Files (*.twin)", "*.twin"
parts = Split(dlg.Filter, "|")
Debug.Print parts(UBound(parts) - 1)   ' twinBASIC Files (*.twin)
Debug.Print parts(UBound(parts))       ' *.twin

See Also