DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Problem referencing image from resource file to picturebox

  1. #1
    Join Date
    Aug 2007

    Problem referencing image from resource file to picturebox

    I am trying to link a PictureBox in Form1 with an image in my Resource file.

    If I type it in like:
    Dim pic1 As New Bitmap(My.Resources.h22)
    PictureBox2.Image = pic1
    It works fine. However, I won't know the name of the file to just type it in like that. The name is calculated and stored in a string. Here's what I came up with to display the picture:

    Dim MyImagePlace As String = "My.Resources." & ImageString(0).ToString()
    Dim pic1 As New Bitmap(MyImagePlace)
    PictureBox2.Image = pic1
    where MyImagePlace becomes My.Resources.h22

    But it doesn't work. I get an error that the parameter is not valid. Why does that not display the image, and how can I modify it so it does? Thanks!

  2. #2
    Join Date
    Nov 2003
    Portland, OR
    I don't think you can use My.Resources unless you know the resource name at compile time. Try this technique instead:
    Phil Weber

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. File Rename Problem
    By WanHung in forum Java
    Replies: 1
    Last Post: 08-28-2006, 06:16 PM
  2. Replies: 0
    Last Post: 08-28-2006, 01:58 AM
  3. Problem in loading tif image
    By ameya_amu in forum VB Classic
    Replies: 0
    Last Post: 07-03-2006, 12:56 AM
  4. Replies: 0
    Last Post: 02-12-2006, 07:27 PM
  5. ASP.NET problem with XML file
    By rgcr in forum ASP.NET
    Replies: 14
    Last Post: 10-20-2005, 07:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center