473,585 Members | 2,657 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using an OpenFileDialog in VB.NET

4 New Member
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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub BtnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBrowse.Click
  2.         With OpenFileDialog1
  3.             .Title = "Media File Browser"
  4.             .Filter = "Media Files (*.wmv;*.mp3)|*.wmv;*.mp3"
  5.             .FileName = ""
  6.             .CheckFileExists = True
  7.         End With
  8.  
  9.         If OpenFileDialog1.ShowDialog = _
  10.         Windows.Forms.DialogResult.OK Then
  11.             AxWindowsMediaPlayer1.URL = _
  12.             OpenFileDialog1.Filename
  13.         End If
  14.     End Sub
  15. End Class
But the OpenFileDialog1 is underlined in blue, and VBexpress says there is an error.

Any help would be helpful, thanks

Luke
Aug 26 '07 #1
7 5054
Killer42
8,435 Recognized Expert Expert
... 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.
Aug 27 '07 #2
lhacker22
4 New Member
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
Aug 27 '07 #3
SammyB
807 Recognized Expert Contributor
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
Aug 27 '07 #4
lhacker22
4 New Member
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
Aug 28 '07 #5
Killer42
8,435 Recognized Expert Expert
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.
Aug 29 '07 #6
vb08isgreat
5 New Member
ahhh!!!!!!!!!!! !!!!!!!
I was having the exact same problem and now its solved!!
Thanks!
Feb 22 '08 #7
Killer42
8,435 Recognized Expert Expert
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.
Feb 22 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1566
by: violin wang | last post by:
hi I wrote a windows based program.The main UI named form_base has a button "btn1".In btn1`s click event handler I used ShowDialog(this) to show another form named form_test.form_test also has a button btn2 and I added a openfiledialog in form_test.In btn2 click event handler I used ShowDialog(this) to show openfiledialog. When I ran the...
2
5725
by: Bonzo | last post by:
Hi, How do I simply open a text file into a textbox? I know that in C++ I'd use something like: if(OpenDialog1->Execute()) Memo1->Lines->LoadFromFile(OpenDialog1->FileName); How can I do it in vsnet c#? THX
2
3073
by: don | last post by:
has anyone experienced problems with interactions between OpenFileDialog and FileStream? When I select "open" from an OpenFileDialog the subsequent calls to FileStream do not create a file. If I do anything else, eg, navigate to other folders, and then press "cancel" the file is created. This occurrs just with the simple code below. Any ideas...
8
6037
by: e-mid | last post by:
why does not openFileDialog have closed event? i want to do something; as soon as the dialog closes. is there a way to do this?
1
4940
by: Austin Jan | last post by:
Hi all, In this code snip try { using(OpenFileDialog dlg = new OpenFileDialog()) { //do something }
8
2238
by: Burt | last post by:
I am new to VC++ and .NET, so this is a pretty basic question... I want to use OpenFileDialog. Where is the header for it? And in general, how do I find the right header to include in cases like this within .NET? I would thought that #include <OpenFileDialog.h> would do the trick, but there ain't no such beast apparently.
2
1753
by: Willem | last post by:
Hi, I am creating a web application in asp.net in which I have to show an openfiledialog box to select the file and display the selected file with its path in a text box. I try to solve this problem with the System.Windows.Forms.OpenFileFialog. I use Imports System.Windows.Forms
8
6075
by: marcus.kwok | last post by:
I am having a weird problem and I have can't figure out why it is happening. I create an OpenFileDialog and set a filename filter. When the dialog first opens, the filter works correctly, and only the files I want to see appear in the file list box. When I change the filter to one of the other filters, all the files in the list disappear. ...
0
1178
by: Gregaz | last post by:
I have a form in my project, which I open as a DialogBox. On that that form there are 3 TextBoxes. To one of them I want to write in a file path. To have it easier I have an OpenFileDialog control on my form. Selected file path is written in to th TextBox. OpenFileDialog is open by click on a Button. There is other Button on the form run...
3
3245
by: Martijn Mulder | last post by:
It strikes me that System.Windows.Forms.OpenFileDialog seems te 'remember' which directory it was in last, even when a new OpenFileDialog-object is created for every access to the file system. This 'persistence' also holds between different invocations of the same program. Even when the .cs file is re-compiled, the OpenFileDialog again opens...
0
7908
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8212
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.