473,508 Members | 2,008 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 5041
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 'OpenFileDialog1' is not declared. Line 9, Column 14.
2. Name 'OpenFileDialog1' is not declared. Line 16, Column 12.
3. Name 'OpenFileDialog1' 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
1551
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...
2
5718
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...
2
3067
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...
8
6030
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
4934
by: Austin Jan | last post by:
Hi all, In this code snip try { using(OpenFileDialog dlg = new OpenFileDialog()) { //do something }
8
2231
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...
2
1745
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...
8
6060
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...
0
1173
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...
3
3232
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....
0
7331
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,...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5633
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,...
1
5056
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...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.