|
-
Feb 1st, 2005, 08:20 PM
#1
Thread Starter
Junior Member
Help With the Common Dialog...
Yes.. i need help w/ the Common Dialog. I wrote this code that allowed only one file at a time to be loaded into a llist box and be played in the media player.. then i searched a bit on the internet and i found this multiple file opener.. now.. i just need some help puting the write code together. Look at the first code i wrote.. then the second is the multiple file opener... Thanks for the help.. i canta wait to become active in this forum
First Code
VB Code:
Private Sub Command1_Click()
On Error Resume Next
CommonDialog1.Filter = "Audio Files|*.wav;*.mid;*.mp3;mp2;*.mod|"
CommonDialog1.Flags = cdlOFNHideReadOnly
CommonDialog1.CancelError = True
CommonDialog1.DialogTitle = "Choose an mediafile to open"
CommonDialog1.FileName = ""
CommonDialog1.ShowOpen
List1.AddItem CommonDialog1.FileName
List1.ListIndex = List1.ListIndex + 1
MediaPlayer1.FileName = CommonDialog1.FileName
Label1.Caption = CommonDialog1.FileName
End Sub
Second Code For multiple open
VB Code:
Private Sub Command1_Click()
Dim entries As Variant
Dim dir_name As String
Dim i As Integer
On Error Resume Next
CommonDialog1.ShowOpen
If err.Number = cdlCancel Then
Exit Sub
ElseIf err.Number <> 0 Then
MsgBox "Error " & Format$(err.Number) & _
" selecting files." & vbCrLf & err.Description
Exit Sub
End If
List1.Clear
entries = Split(CommonDialog1.FileName, vbNullChar)
' See if there is more than one file.
If UBound(entries, 1) = LBound(entries, 1) Then
' There is only one file name.
List1.AddItem entries(LBound(entries, 1))
Else
' Get the directory name.
dir_name = entries(LBound(entries, 1))
If Right$(dir_name, 1) <> "\" Then dir_name = dir_name & "\"
' Get the file names.
For i = LBound(entries, 1) + 1 To UBound(entries, 1)
List1.AddItem dir_name & entries(i)
Next i
End If
End Sub
I want the multiple file opener and do the same thing the first code does.. if u can help thanks a bunch
-
Feb 1st, 2005, 08:28 PM
#2
Member
Re: Help With the Common Dialog...
I think the problem is at this line
Entries = Split(CommonDialog1.FileName, vbNullChar)
The vbNullChar should only be at the end of CommonDialog1.FileName
The proper delimiter, if I recall, is the space character.
Entries = Split(CommonDialog1.FileName, " ")
Replace that and see if it solves your problem, I'm pretty sure it will
When they say it can't be done, THAT's when they call me ;-)
MystikShadows
JC-Hosting.net
-
Feb 1st, 2005, 08:32 PM
#3
Thread Starter
Junior Member
Re: Help With the Common Dialog...
no the multiple opening works.. i just want it to open multiple files and do this
List1.AddItem CommonDialog1.FileName
List1.ListIndex = List1.ListIndex + 1
MediaPlayer1.FileName = CommonDialog1.FileName
Label1.Caption = CommonDialog1.FileName
cause if i add that code to the multiple opener then it opens 1 file and if i want to add another one it deletes the first one then adds the new one..
-
Feb 1st, 2005, 08:40 PM
#4
Member
Re: Help With the Common Dialog...
HAve you tried concatenating them then?
MediaPlayer1.Filename = "file1.mp3;file2.mp3;file3.mp3" etc etc...
Basically once you retreive the multiply names from the commondialog, you could do this
Change entries to be a string instead of an array, Then
Entries = Replace(Commondialog1.file, " ", ";")
And then
MedialPlayer1.Filename = Entries
Last edited by MystikShadows; Feb 1st, 2005 at 08:43 PM.
When they say it can't be done, THAT's when they call me ;-)
MystikShadows
JC-Hosting.net
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
|