| | |
resources folder
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 91
Reputation:
Solved Threads: 0
Hello everyone!
I had a quick question on how to use pictures in a VB program. What I'm trying to do is when someone selects an item in a listbox, to show the corresponding jpg file. I selected the relevant jpgs from the desktop, copied them to the clipboard and then pasted them into the resources folder by right clicking on resoruces in the solution explorer and selecting paste and now they are listed under resources.
However, when I goto run the program and select one of the listbox items, I get a FileNotFoundException. The names of the files that I use in the code match those of the jpeg files that I want to use in resources. I don't understand what I'm doing wrong.
Thanks.
Here's a copy of the relevant code....
I had a quick question on how to use pictures in a VB program. What I'm trying to do is when someone selects an item in a listbox, to show the corresponding jpg file. I selected the relevant jpgs from the desktop, copied them to the clipboard and then pasted them into the resources folder by right clicking on resoruces in the solution explorer and selecting paste and now they are listed under resources.
However, when I goto run the program and select one of the listbox items, I get a FileNotFoundException. The names of the files that I use in the code match those of the jpeg files that I want to use in resources. I don't understand what I'm doing wrong.
Thanks.
Here's a copy of the relevant code....
VB.NET Syntax (Toggle Plain Text)
If lstCarpets.SelectedIndex = 0 Then picCarpet.Image = Image.FromFile("modern_geometric.jpg") ElseIf lstCarpets.SelectedIndex = 1 Then picCarpet.Image = Image.FromFile("tufenkian.jpg") ElseIf lstCarpets.SelectedIndex = 2 Then picCarpet.Image = Image.FromFile("MosqueDomee.jpg")
Last edited by Ancient Dragon; Feb 9th, 2009 at 11:09 pm. Reason: add code tags
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
You still have to tell it where the file is. It it something I have always had trouble with because your program is run in bin subdirectory and either debug subdirectory or release subdirectory and your folder isn't there it is two folders back.
What I do is copy the files into the resources and use them from there. Then you can use:
picCarpet.Image = My.Resources.modern_geometric.jpg
What I do is copy the files into the resources and use them from there. Then you can use:
picCarpet.Image = My.Resources.modern_geometric.jpg
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
•
•
Join Date: Apr 2008
Posts: 91
Reputation:
Solved Threads: 0
•
•
•
•
You still have to tell it where the file is. It it something I have always had trouble with because your program is run in bin subdirectory and either debug subdirectory or release subdirectory and your folder isn't there it is two folders back.
What I do is copy the files into the resources and use them from there. Then you can use:
picCarpet.Image = My.Resources.modern_geometric.jpg
Thanks.
Last edited by Trekker182; Feb 9th, 2009 at 11:34 pm.
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
You have to copy the images into the resources. Copy your images to the clipboard. Double click on the MyProjects in the Solution Explorer. Click on the resources tab. Now right click on the background and select paste. Now all your images are resources. Now you can use your code.
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
![]() |
Similar Threads
- Store and retrieve numerous .wav and .bmp files (VB.NET)
- Visual C++ 2008 playing a sound (C++)
- windows explorer using 98% CPU, new installation winxp pro (Viruses, Spyware and other Nasties)
- Motherboard Resources has no driver. Audio not working (Motherboards, CPUs and RAM)
- Can't find 'Folder Options' (Viruses, Spyware and other Nasties)
- Help!! (Networking Hardware Configuration)
- Low Resources Windows 98SE (Windows 95 / 98 / Me)
- Winlogon.exe sucking cpu resources. (Windows NT / 2000 / XP)
- Printer operation cannot continue due to lack of resources. (Windows NT / 2000 / XP)
Other Threads in the VB.NET Forum
- Previous Thread: Loading messengers via VB tool
- Next Thread: player
| Thread Tools | Search this Thread |
.net .net2008 30minutes 2005 2008 access account arithmetic array basic bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dropdownlist excel fade file-dialog filter folder ftp generatetags google gridview hardcopy images input insert intel internet mobile monitor ms net networking objects output panel passingparameters peertopeervideostreaming picturebox picturebox1 port position print printing problem problemwithinstallation project save searchbox searchvb.net select serial shutdown soap survey table tcp temperature text textbox timer timespan toolbox trim update updown user vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf year





