OpenFile Dialog Box
The OpenFileDialog component displays a dialog box that allows the user to choose a file to open.

The FileName property can be set prior to showing the dialog box. This causes the dialog box to initially display the given filename. In most cases, your applications should set the InitialDirectory, Filter, and FilterIndex properties prior to calling ShowDialog.
The following VB.Net program invites an OpenFile Dialog Box and retrieve the selected filename to a string.
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dlg As New OpenFileDialog dlg.ShowDialog() If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then Dim fileName As String fileName = dlg.FileName MsgBox(fileName) End If End Sub End Class
Related Topics
- Visual Studio IDE
- How to Create a vb.net Windows Forms Application
- Label Control
- Button Control
- TextBox Control
- ComboBox Control
- ListBox Control
- Checked ListBox Control
- RadioButton Control
- CheckBox Control
- PictureBox Control
- ProgressBar Control
- ScrollBars Control
- DateTimePicker Control
- Treeview Control
- ListView Control
- Menu Control
- MDI Form
- Color Dialog Box
- Font Dialog Box
- Print Dialog Box
- KeyPress event in VB.NET
- How to create Dynamic Controls in VB.NET ?
- How do i keep a form on top of others
- Timer Control - VB.Net