Skip to content

Dialog Methods Reference

📋 Method List

MethodDescription
ShowOpenShow open file dialog
ShowSaveShow save file dialog
ShowBrowseForFolderShow select folder dialog
SelectFilesSelect files and return collection
SelectAndOpenFileSelect file and open
OpenFileOpen specified file
AddFilterAdd file filter
ClearFilterClear all filters
SetCommonFiltersSet common filters
SetImageFiltersSet image filters
SetDocumentFiltersSet document filters
SetCodeFiltersSet code filters
GetFilePathGet file path (without filename)
GetFileNameGet filename (with extension)
GetFileExtensionGet file extension
GetFileNameWithoutExtGet filename (without extension)
ResetReset to default settings

📂 ShowOpen Method

Description

Shows open file dialog. Returns selected file path, supports multi-select.

Syntax

vb
Public Function ShowOpen() As Variant

Return Value

  • Single select mode: Returns file path string, returns empty string on cancel
  • Multi-select mode (MultiSelect=True): Returns file path array

Example

Single File Selection

vb
Dim dlg As New cDialog
dlg.DialogTitle = "Open File"
dlg.InitialDir = "C:\Documents"
dlg.AddFilter "Text Files", "*.txt"
dlg.AddFilter "All Files", "*.*"

Dim filePath As String
filePath = dlg.ShowOpen

If filePath <> "" Then
    Debug.Print "Selected file: " & filePath
End If

Multi-File Selection

vb
dlg.MultiSelect = True

Dim result As Variant
result = dlg.ShowOpen

If IsArray(result) Then
    Dim i As Long
    For i = LBound(result) To UBound(result)
        Debug.Print "File " & i & ": " & result(i)
    Next i
ElseIf result <> "" Then
    Debug.Print "Single file: " & result
End If

💾 ShowSave Method

Description

Shows save file dialog.

Syntax

vb
Public Function ShowSave() As String

Return Value

Returns save path string, returns empty string on cancel.

Example

vb
Dim dlg As New cDialog
dlg.DialogTitle = "Save File"
dlg.DefaultExt = "txt"
dlg.FileName = "New Document.txt"
dlg.InitialDir = "C:\Documents"
dlg.AddFilter "Text Files", "*.txt"
dlg.AddFilter "All Files", "*.*"

Dim savePath As String
savePath = dlg.ShowSave

If savePath <> "" Then
    Debug.Print "Save to: " & savePath
    ' Execute save operation
End If

📁 ShowBrowseForFolder Method

Description

Shows select folder dialog.

Syntax

vb
Public Function ShowBrowseForFolder() As String

Return Value

Returns selected folder path, returns empty string on cancel.

Example

vb
Dim dlg As New cDialog
dlg.DialogTitle = "Please select output folder"
dlg.NewDialogStyle = True  ' Use new style (with edit box)

Dim folderPath As String
folderPath = dlg.ShowBrowseForFolder

If folderPath <> "" Then
    Debug.Print "Selected folder: " & folderPath
End If

📋 SelectFiles Method

Description

Shows open file dialog, returns selected file collection (Collection).

Syntax

vb
Public Function SelectFiles() As Collection

Return Value

Returns Collection object containing file paths.

Example

vb
Dim dlg As New cDialog
dlg.DialogTitle = "Select Files"
dlg.MultiSelect = True
dlg.AddFilter "All Files", "*.*"

Dim files As Collection
Set files = dlg.SelectFiles

Debug.Print "Selected " & files.Count & " files"

Dim file As Variant
For Each file In files
    Debug.Print file
Next file

🚀 SelectAndOpenFile Method

Description

Shows open file dialog and automatically opens the selected file.

Syntax

vb
Public Function SelectAndOpenFile() As Long

Return Value

Returns ShellExecute result.

Example

vb
Dim dlg As New cDialog
dlg.DialogTitle = "Select file to open"
dlg.AddFilter "Executable Files", "*.exe"

dlg.SelectAndOpenFile  ' Auto open after selection

📂 OpenFile Method

Description

Opens specified file using ShellExecute.

Syntax

vb
Public Function OpenFile(ByVal strFilePath As String, Optional ByVal strOperation As String = "open") As Long

Parameters

ParameterTypeDescription
strFilePathStringFile path to open
strOperationStringOperation type, default "open"

Example

vb
Dim dlg As New cDialog
dlg.OpenFile "C:\Documents\file.txt"       ' Open with default program
dlg.OpenFile "C:\Documents\file.txt", "edit"  ' Open for editing

➕ AddFilter Method

Description

Adds a file filter.

Syntax

vb
Public Sub AddFilter(ByVal strDescription As String, ByVal strExtension As String)

Parameters

ParameterTypeDescription
strDescriptionStringFilter description
strExtensionStringFile extension pattern

Example

vb
dlg.AddFilter "Text Files", "*.txt"
dlg.AddFilter "Image Files", "*.jpg;*.png;*.gif"
dlg.AddFilter "All Files", "*.*"

🧹 ClearFilter Method

Description

Clears all file filters.

Syntax

vb
Public Sub ClearFilter()

Example

vb
dlg.ClearFilter  ' Clear previous filters
dlg.AddFilter "New Type", "*.new"

📋 Preset Filter Methods

SetCommonFilters

Sets common file filters (text files, all files).

vb
dlg.SetCommonFilters

SetImageFilters

Sets image file filters.

vb
dlg.SetImageFilters  ' Contains bmp, jpg, png, gif, etc.

SetDocumentFilters

Sets document file filters.

vb
dlg.SetDocumentFilters  ' Contains doc, xls, ppt, pdf, etc.

SetCodeFilters

Sets code file filters.

vb
dlg.SetCodeFilters  ' Contains bas, c, cs, java, py, js, etc.

🔧 File Path Utility Methods

GetFilePath

Gets the directory path of a file.

vb
Dim path As String
path = dlg.GetFilePath("C:\Folder\file.txt")  ' Returns "C:\Folder"

GetFileName

Gets filename (with extension).

vb
Dim name As String
name = dlg.GetFileName("C:\Folder\file.txt")  ' Returns "file.txt"

GetFileExtension

Gets file extension (with dot).

vb
Dim ext As String
ext = dlg.GetFileExtension("C:\Folder\file.txt")  ' Returns ".txt"

GetFileNameWithoutExt

Gets filename (without extension).

vb
Dim name As String
name = dlg.GetFileNameWithoutExt("C:\Folder\file.txt")  ' Returns "file"

🔄 Reset Method

Description

Resets all settings to default values.

Syntax

vb
Public Sub Reset()

Example

vb
dlg.Reset  ' Clear all settings, restore initial state

Last Updated: 2026-05-17

VB6 and LOGO copyright of Microsoft Corporation