Covert string to image resouce vb.net

The following code is used to load an image.....

picMA.Image = My.Resources.gauge_25
picMA.SizeMode = PictureBoxSizeMode.Zoom

But i need to set the "gauge_25" as a variable

Is this possible, why i try i get an error in the conversion?

Thanks in advance
SweetingAAsked:
Who is Participating?
 
MattiConnect With a Mentor Commented:
picMA.Image = My.Resources.gauge_25 as object

or

picMA.Picture = My.Resources.gauge_25 as object

try there is very little code on both sides
0
 
MattiCommented:
use object variable if you wan to load a picture in a variable. explaining image formats as basics and how to save them as bytes here is a bit matter of copyrights who has them and what type of image.
0
 
SweetingAAuthor Commented:
I'm afraid i am a real novice, how do i do that?
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
SweetingAAuthor Commented:
I have tried this where MA =0.84
MA is declared as Double

i have tried delcaring img as a string and as an object        

img = "Gauge-" & Int(MA) & ".png"
picMA.Image = My.Resources.ResourceManager.GetObject(img)
picMA.SizeMode = PictureBoxSizeMode.Zoom

When i run it, no picture is displayed
0
 
SweetingAAuthor Commented:
Hi Matti,

Sorry i just don't get it, i want assign any 1 of 150 pictures depending on certain criteria (i.e. the value of MA) so i need the .Gauge_25 part to be a variable

Thanks
0
 
Jacques Bourgeois (James Burger)PresidentCommented:
picMA.Image = DirectCast(My.Resources.ResourceManager.GetObject("gauge_25"), Image)

If DirectCast does not work, try replacing it by CType.
0
 
David Johnson, CD, MVPOwnerCommented:
are you trying to display a number as an image?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.