?
Solved

Covert string to image resouce vb.net

Posted on 2014-02-06
7
Medium Priority
?
252 Views
Last Modified: 2014-02-10
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
0
Comment
Question by:SweetingA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 14

Expert Comment

by:Matti
ID: 39840069
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
 

Author Comment

by:SweetingA
ID: 39840178
I'm afraid i am a real novice, how do i do that?
0
 
LVL 14

Accepted Solution

by:
Matti earned 2000 total points
ID: 39840249
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
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 

Author Comment

by:SweetingA
ID: 39840261
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
 

Author Comment

by:SweetingA
ID: 39840291
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
 
LVL 40
ID: 39840535
picMA.Image = DirectCast(My.Resources.ResourceManager.GetObject("gauge_25"), Image)

If DirectCast does not work, try replacing it by CType.
0
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 39840662
are you trying to display a number as an image?
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question