Search code examples
vb.netstringtypeconverter

Value of type 'String' cannot be converted to 'System.Drawing.Image'


PictureBox1.Image = "WindowsApplication4.My.Resources.Resources._" & itemno.Text

Hi, i have a bunch of pictures, all numbered from (1-100) and, when the user enters a number into the "itemno" input box, the picturebox1.image changes accordingly. How do i implement something like in the code example above?


Solution

  • You can use the ResourceManager to get a resource by name.

    PictureBox1.Image = DirectCast(My.Resources.ResourceManager.GetObject("name_of_image"), Bitmap)