Results 1 to 4 of 4

Thread: Help With the Common Dialog...

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    25

    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:
    1. Private Sub Command1_Click()
    2. On Error Resume Next
    3. CommonDialog1.Filter = "Audio Files|*.wav;*.mid;*.mp3;mp2;*.mod|"
    4. CommonDialog1.Flags = cdlOFNHideReadOnly
    5. CommonDialog1.CancelError = True
    6. CommonDialog1.DialogTitle = "Choose an mediafile to open"
    7. CommonDialog1.FileName = ""
    8. CommonDialog1.ShowOpen
    9.  
    10. List1.AddItem CommonDialog1.FileName
    11. List1.ListIndex = List1.ListIndex + 1
    12. MediaPlayer1.FileName = CommonDialog1.FileName
    13. Label1.Caption = CommonDialog1.FileName
    14. End Sub



    Second Code For multiple open

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim entries As Variant
    3. Dim dir_name As String
    4. Dim i As Integer
    5.  
    6.     On Error Resume Next
    7.     CommonDialog1.ShowOpen
    8.     If err.Number = cdlCancel Then
    9.         Exit Sub
    10.     ElseIf err.Number <> 0 Then
    11.         MsgBox "Error " & Format$(err.Number) & _
    12.             " selecting files." & vbCrLf & err.Description
    13.             Exit Sub
    14.     End If
    15.  
    16.     List1.Clear
    17.     entries = Split(CommonDialog1.FileName, vbNullChar)
    18.  
    19.     ' See if there is more than one file.
    20.     If UBound(entries, 1) = LBound(entries, 1) Then
    21.         ' There is only one file name.
    22.         List1.AddItem entries(LBound(entries, 1))
    23.     Else
    24.         ' Get the directory name.
    25.         dir_name = entries(LBound(entries, 1))
    26.         If Right$(dir_name, 1) <> "\" Then dir_name = dir_name & "\"
    27.  
    28.         ' Get the file names.
    29.         For i = LBound(entries, 1) + 1 To UBound(entries, 1)
    30.             List1.AddItem dir_name & entries(i)
    31.         Next i
    32.     End If
    33. End Sub

    I want the multiple file opener and do the same thing the first code does.. if u can help thanks a bunch

  2. #2

    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    25

    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..

  4. #4

    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
  •  



Click Here to Expand Forum to Full Width