resources folder

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Apr 2008
Posts: 91
Reputation: Trekker182 is an unknown quantity at this point 
Solved Threads: 0
Trekker182 Trekker182 is offline Offline
Junior Poster in Training

resources folder

 
0
  #1
Feb 9th, 2009
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....
  1. If lstCarpets.SelectedIndex = 0 Then
  2. picCarpet.Image = Image.FromFile("modern_geometric.jpg")
  3. ElseIf lstCarpets.SelectedIndex = 1 Then
  4. picCarpet.Image = Image.FromFile("tufenkian.jpg")
  5. ElseIf lstCarpets.SelectedIndex = 2 Then
  6. picCarpet.Image = Image.FromFile("MosqueDomee.jpg")
Last edited by Ancient Dragon; Feb 9th, 2009 at 11:09 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: resources folder

 
0
  #2
Feb 9th, 2009
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
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 91
Reputation: Trekker182 is an unknown quantity at this point 
Solved Threads: 0
Trekker182 Trekker182 is offline Offline
Junior Poster in Training

Re: resources folder

 
0
  #3
Feb 9th, 2009
Originally Posted by waynespangler View Post
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
Where is the best place to put that? When I put it just after each if elseif statement, I get a message that the picture is not a member of resources.

Thanks.
Last edited by Trekker182; Feb 9th, 2009 at 11:34 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: resources folder

 
0
  #4
Feb 10th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 91
Reputation: Trekker182 is an unknown quantity at this point 
Solved Threads: 0
Trekker182 Trekker182 is offline Offline
Junior Poster in Training

Re: resources folder

 
0
  #5
Feb 10th, 2009
I tried that and it still didn't work.

I ended up having to copy the jpg files into both the bin/debug/resources folder as well as resources...now when I click on a list item, BAM...the related pic shows up!
Last edited by Trekker182; Feb 10th, 2009 at 11:30 pm.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC