Filter

This property returns and sets the filters that are displayed in the Type list of a dialog box.

Syntax

object.Filter [= description1|filter1|description2|filter2…]

Parameters

object
Object expression that evaluates to a CommonDialog control.
description
String expression that describes the type of file.
filter
String expression that specifies the file name extension.

Remarks

A filter specifies the types of file displayed in a dialog box's file list box. For example, selecting the filter *.txt displays all text files.

Use this property to provide a user with a list of filters that can be selected when the dialog box is displayed.

Use the pipe ( | ) symbol (ASCII 124) to separate the description and filter values. Do not include spaces before or after the pipe symbol, because these spaces will be displayed with the description and filter values.

The following code example shows a filter that enables the user to select text files or graphic files that include bitmaps and icons.

Text (*.txt)|*.txt|Pictures (*.bmp;*.ico)|*.bmp;*.ico

When you specify more than one filter for a dialog box, use the FilterIndex property to determine which filter is displayed as the default.