Skip to content

Dialog Component Overview

📖 Introduction

cDialog is a Windows standard dialog wrapper class providing common dialog functionality such as open file, save file, select folder, supporting file filtering, multi-select, and other features.

✨ Key Features

FeatureDescription
Open File DialogSupports single select, multi-select, file filtering
Save File DialogSupports overwrite prompt, default extension
Select Folder DialogSupports new style dialog
Preset FiltersText, image, document, code and other preset filters
File Path UtilitiesExtract path, filename, extension, etc.
Open FileOpen selected file using ShellExecute

🚀 Quick Start

Open File

vb
Dim dlg As New cDialog

dlg.DialogTitle = "Select 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

Save File

vb
Dim dlg As New cDialog

dlg.DialogTitle = "Save File"
dlg.DefaultExt = "txt"
dlg.FileName = "New Document.txt"
dlg.AddFilter "Text Files", "*.txt"

Dim savePath As String
savePath = dlg.ShowSave

If savePath <> "" Then
    Debug.Print "Save to: " & savePath
End If

Select Folder

vb
Dim dlg As New cDialog

dlg.DialogTitle = "Select Folder"

Dim folderPath As String
folderPath = dlg.ShowBrowseForFolder

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

Using Preset Filters

vb
Dim dlg As New cDialog

' Use image filter
dlg.SetImageFilters
Dim imgFile As String
imgFile = dlg.ShowOpen

' Use document filter
dlg.SetDocumentFilters
Dim docFile As String
docFile = dlg.ShowOpen

Usage Example

vb
'-----------------------------------------------
' Event: btnBrowse_Click (Browse button)
' Description: Open file selection dialog
'-----------------------------------------------
Private Sub btnBrowse_Click()
    With New cDialog
        .ClearFilter
        .AddFilter "All Files (*.*)", "*.*"
        .DialogTitle = "Select file to upload"
        .FileMustExist = True
        .PathMustExist = True

        With .SelectFiles()
            If .Count > 0 Then
                mSelectedFile = .Item(1)
                txtFilePath.Text = mSelectedFile
                lblStatus.Caption = "File size: " & VBMAN.Formater(FileLen(mSelectedFile)).ReturnFileSize()
                btnUpload.Enabled = True
            End If
        End With
    End With
End Sub

📁 Documentation Navigation


Last Updated: 2026-05-17

VB6 and LOGO copyright of Microsoft Corporation