|
-
Aug 26th, 2007, 01:41 PM
#1
[RESOLVED] Selecting various files in a CommonDialog
In a commondialog I set this flag:
CommonDialog1.FLAGS = cdlOFNAllowMultiselect
so various files can be selected. Then, in
CommonDialog1.FileName
the path and the names of the selected files are returned separated by null characters:
Path & Chr(0) & File1 & Chr(0) & ... & Chr(0) & FileN
so that I can retrive the individual file names using a split statement.
Is there an easier way I'm not aware of?
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Aug 26th, 2007, 01:58 PM
#2
Re: Selecting various files in a CommonDialog
That would the easiest way, IMHO.
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Aug 27th, 2007, 12:38 PM
#3
Re: Selecting various files in a CommonDialog
I agree, and here is how I would do it
Code:
Dim i As Long
Dim sArrFileList() As String
sArrFileList = Split(CommonDialog1.FileName, Chr(0))
For i = 0 To UBound(sArrFileList())
List1.AddItem sArrFileList(i) 'Listbox used as an example only
Next
-
Aug 27th, 2007, 05:45 PM
#4
Re: Selecting various files in a CommonDialog
 Originally Posted by Hack
I agree, and here is how I would do it
Code:
Dim i As Long
Dim sArrFileList() As String
sArrFileList = Split(CommonDialog1.FileName, Chr(0))
For i = 0 To UBound(sArrFileList())
List1.AddItem sArrFileList(i) 'Listbox used as an example only
Next
Yeah, that's more or less my approach. But some care had to be taken anyway. I can't remember what the trouble was so I just transcribe the working code.
Code:
ohndc = Split(CommonDialog1.FileName, Chr$(0))
NFiles = UBound(ohndc)
If NFiles = 0 Then
NFiles = 1
'Working with option base 1
ReDim FileFullPath(1 To NFiles)
ReDim File(1 To NFiles)
FileFullPath(1) = CommonDialog1.FileName
File(1) = CommonDialog1.FileTitle
Else
ReDim FileFullPath(1 To NFiles)
ReDim File(1 To NFiles)
PathOnly = ohndc(0) & "\"
For i = 1 To UBound(ohndc)
File(i) = ohndc(i)
FileFullPath(i) = PathOnly & File(i)
Next
End If
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|