Question:
Using VB6.0 Common Dialog commands, does anyone know how to select MORE than 1 file at a time?
anonymous
2007-12-03 13:59:14 UTC
Using VB6.0 Common Dialog commands, does anyone know how to select MORE than 1 file at a time?
Three answers:
?
2007-12-03 17:50:39 UTC
You need to set the flags property. You can use a single flag or combine several different flags by using an OR between each flag.



CommonDialog1.Flags = cdlOFNExplorer OR cdlOFNAllowMultiselect (all on one line)



CommonDialog1.Flags = &H80000 OR &H200



VB provides constants for the flag values. You can also use the HEX values instaead or wriye your own constant variables using shorter names



***** WARNING *******



Multi files are returned as a single string starting with the path and all files concatenated together with a delimiter character between each.

Depending on the flags you set the seperator can be either a space or a null. The delimiter used depends on wether or not you are able to view long file names. If short file names are used a Space is the delimiter. If Long file names are used (as in my example) a null is used to delimit the files.



This code uses the split function to extract the path and files.

I have also defined my own null seperator rather than use VbNull as the seperator in the split function. I sometimes have problems using VbNull.



Dim strFiles() As String 'array to hold the split files

Dim intCnt As Integer ' count of array elements

Dim Cnt As Integer ' used to index through the array

Dim sep as string 'delimiter character



sep = Chr(0) 'define a null seperator



With Me.CommonDialog1



.Flags = &H80000 Or &H200 'use long filenames

.ShowOpen

Debug.Print (.FileName)

strFiles = Split(.FileName, sep)

intCnt = UBound(strFiles)



For Cnt = 0 To intCnt

Debug.Print (strFiles(Cnt))

Next Cnt



End With
Random Malefactor
2007-12-03 22:14:29 UTC
Try setting the Flags property to cdlOFNAllowMultiselect -- or better yet, OR that flag to its existing flags:



CommonDlg1.Flags = CommonDlg1.Flags Or cdlOFNAllowMultiselect



(Where CommonDlg1 is a Common Dialog Control object.)





Good Luck!
anonymous
2007-12-03 22:14:59 UTC
There's a property for that control called Multi-Select. Set that to true


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...