Solved

Covert string to image resouce vb.net

Posted on 2014-02-06
7
228 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
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 500 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 78

Expert Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now