HOWTO: Retrieve Multiple Filenames from Common Dialog ControlLast reviewed: July 17, 1997Article ID: Q145612 |
The information in this article applies to:
SUMMARYThe Common Dialog File control allows you to select one or more files to use in your Visual Basic application program. This article shows how to retrieve the names of the selected files from the Common Dialog control.
MORE INFORMATIONVisual Basic's Common Dialog File control allows you to provide access to the directory and file structure of your hard disk from within an application program. For example, if your user needs to select a text file, you can display a Common Dialog File Control box and the user can traverse the directories until he finds the individual file he wants to access. By setting the Flags property of the Common Dialog control to the constant value OFN_ALLOWMULTISELECT, your user may select several files to work with. Multiple files can be selected by clicking on each filename while holding down the SHIFT or CTRL key. The selected filenames are highlighted. When your Visual Basic program needs to work with the files selected by the user, you need to retrieve each individual filename from the control's Filename property. The filenames selected by the user are all stored in this property as one long string. Each filename is separated by a space (32) character. Therefore, to retrieve each individual filename from the Common Dialog's Filename property, you use the InStr function to search for the delimiting space character. The InStr function returns the location of the space character within the Filename property string. Next, you use the Mid function to remove the individual filename entry from the string.
Create the Demonstration ProgramThe demonstration program below shows how to retrieve all filenames selected in a Common Dialog File control.
REFERENCESProduct Documentation, Officer Developer's Kit, Visual Basic 3.0 Professional Edition. Common Dialog Control |
Keywords : PrgCtrls vb4all vb4win vb5all vb5howto kbhowto
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |