VB icon

Display the File Open Dialog

Email
Submitted on: 1/1/2015 1:43:00 AM
By: Melxium CG (from psc cd)  
Level: Beginner
User Rating: By 5 Users
Compatibility: VB.NET
Views: 1227
 
     Display the windows common file open dialog to select files. File filters, multi-select, starting directory. Requires no ActiveX or OXC controls on the form.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
// for :Display the File Open Dialog
//**************************************
SoftTech InterCorp:
Please visit our corporate home page: http://www.stintercorp.com/
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Display the File Open Dialog
// Description:Display the windows common file open dialog to select files. File filters, multi-select, starting directory. Requires no ActiveX or OXC controls on the form.
// By: Melxium CG (from psc cd)
//
// Returns:string / array = files selected
//
// Assumes:'Place code inside any module, form or class. (Will work in sub and function declarations)
//**************************************

'Create Dialog Fuction
Dim fOpenDialog As New OpenFileDialog()
'Variable used for retrival of selected files
Dim sFile As String = ""
'Start of width statement
With fOpenDialog
'Set Filter for the selected files
.Filter = "Supported Images|*.bmp;*.jpg|Bitmap Images|*.bmp|JPEG Images|*.jpg|All Files|*.*"
'Set the title of the selected file
.Title = "Select Image to Open"
'Enable Multi-Select
.Multiselect = True
'make sure all selected files exists
.CheckFileExists = True
'Set initial directory to the users desktop
.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
'show the open dialog
.ShowDialog()
'get each of the selected file and display it in a msgbox
For Each sFile In .FileNames
'display msgbox the current filepath
MsgBox("File: " & sFile)
Next
'clear the dialog from resorces
.Dispose()
End With


Other 3 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.