Using an OpenFileDialog in VB.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lhacker22
    New Member
    • Aug 2007
    • 4

    Using an OpenFileDialog in VB.NET

    Hi there,

    I am currently trying to learn Visual Basic, using Visual Basic Express 2005. I am making a Mulitmedia Player. I have added Windows Media Player via the COM components and dragged it onto the stage, and I have also created a browse... button with the following code:
    [CODE=vbnet]Private Sub BtnBrowse_Click (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles BtnBrowse.Click
    With OpenFileDialog1
    .Title = "Media File Browser"
    .Filter = "Media Files (*.wmv;*.mp3)|* .wmv;*.mp3"
    .FileName = ""
    .CheckFileExist s = True
    End With

    If OpenFileDialog1 .ShowDialog = _
    Windows.Forms.D ialogResult.OK Then
    AxWindowsMediaP layer1.URL = _
    OpenFileDialog1 .Filename
    End If
    End Sub
    End Class[/CODE]

    But the OpenFileDialog1 is underlined in blue, and VBexpress says there is an error.

    Any help would be helpful, thanks

    Luke
    Last edited by Killer42; Aug 27 '07, 03:07 AM. Reason: Changed CODE tag to CODE=vbnet
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by lhacker22
    ... and VBexpress says there is an error.
    Here's a tip. Any time you report an error, be specific. Tell us what error.

    My guess is, in this case, you simply don't have any object called OpenFileDialog1 . However, I'm only familiar with VB6 and things may work differently in your version.
    Last edited by Killer42; Aug 27 '07, 03:08 AM. Reason: Forgot to mis-spell dialogue

    Comment

    • lhacker22
      New Member
      • Aug 2007
      • 4

      #3
      OK, thanks for the tip. The error message is that the "build fails", because of the following:

      1. Name 'OpenFileDialog 1' is not declared. Line 9, Column 14.
      2. Name 'OpenFileDialog 1' is not declared. Line 16, Column 12.
      3. Name 'OpenFileDialog 1' is not declared. Line 19, Column 13.

      Hopefully that is of some help.

      Luke

      Comment

      • SammyB
        Recognized Expert Contributor
        • Mar 2007
        • 807

        #4
        You need to drag an OpenFileDialog from the Toolbox and drop it onto your project. It will go into the tray under your form and OpenFileDialog1 will be defined. Hope your enjoy learning VB. It's tough, but worth the trouble. --Sam

        Comment

        • lhacker22
          New Member
          • Aug 2007
          • 4

          #5
          Originally posted by SammyB
          You need to drag an OpenFileDialog from the Toolbox and drop it onto your project. It will go into the tray under your form and OpenFileDialog1 will be defined. Hope your enjoy learning VB. It's tough, but worth the trouble. --Sam
          Thanks very much, it works wooo
          And i agree VB is hard the more advanced you get, but that is like anythink!
          once again thank you

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by lhacker22
            Thanks very much, it works wooo
            And i agree VB is hard the more advanced you get, but that is like anythink!
            once again thank you
            Like many of the best tools, it is fairly quick and simple to get into, but takes a lot more effort to learn really well.

            Comment

            • vb08isgreat
              New Member
              • Feb 2008
              • 6

              #7
              ahhh!!!!!!!!!!! !!!!!!!
              I was having the exact same problem and now its solved!!
              Thanks!

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Originally posted by vb08isgreat
                i was having the exact same problem and now its solved
                Glad we could help. :)

                That's why all this stuff is archived, of course. So it's available for anyone who comes along with the same problem.

                Comment

                Working...