OpenFileDialog Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Severick
    New Member
    • Aug 2007
    • 1

    OpenFileDialog Question

    Hello, Im new to the forum. I have experienced with VB code and need help with a OpenFileDialog. I am making a small media player for practice. I have a listbox and a cmdAdd button. How will I be able to make a OpenFileDialog to add songs into the listbox?

    Thanks.
  • JonJacobs
    New Member
    • Aug 2007
    • 22

    #2
    Code:
    Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
            Dim Fn As String
            OpenFileDialog1.DefaultExt = MyExpectedExtension
            OpenFileDialog1.InitialDirectory = "C:\MyMusic"
            If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
                Fn = OpenFileDialog1.FileName
            Else
                Exit Sub
            End If
    
            'Do what you want with Fn, the file name of the selected music file
    
        End Sub
    HTH

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by Severick
      Hello, Im new to the forum. I have experienced with VB code and need help with a OpenFileDialog. I am making a small media player for practice. I have a listbox and a cmdAdd button. How will I be able to make a OpenFileDialog to add songs into the listbox?
      What version of VB are you using? If it's VB6 (or even earlier) the posted code won't work. Hopefully you're using a more up-to-date version, though.

      Comment

      Working...