How to read resource file

Hi everyone,
I'm using VS2005.

I've added a pictrure to the resource file.
And show it on the button

The default way to set the image is:
dynpSplitButton.Image = global::Health_Proc.Properties.Resources.AO;

However, I want to set the name AO dynamiccaly,

I mean, I need a function which takes a vairable and returns me the image/object

dim img as string = "AO"
dynpSplitButton.Image = global::Health_Proc.Properties.Resources.getResourceByName(img) <= This function is imaginary.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SwapnilSoftware ArchitectCommented:
Hi tolgaong,

you can get string from resource (.resx) file by

dim resourceCulture as System.Globalization.CultureInfo
dim str as string = System.Resources.ResourceManager.GetString("EventLogEntryHeaderTemplate", resourceCulture)

here "EventLogEntryHeaderTemplate" means your key from this you can get msg.

tolgaongAuthor Commented:
I think the above solutions are not suitable for me.
I have some other urgent jobs for today.

I'll try to rephare my question again tomorrow afternoon.
Thanks for your participation.
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

tolgaongAuthor Commented:
I'm back again. Sorry for the so late return.

Let's do it step by step
1) Create a new VB.NET project
2) Click "Show All files"
3) Expand My Project
4) Select Resources.resx
5) Right click and select "Open"
6) Select Images from the toolbar (Left upper drop down button)
7) Select Add Existing File from Add Resource (Next to the previous button) [I've added the zapotec file from c:\windows]
8) Select and double click to form1 (to create form_load event)
9) Write: PictureBox1.Image = Global.ResourceFile.My.Resources.Zapotec
10) Run. It works.

What I want is to get the file name as a string
For example:
11) Put a textbox and a button to the form.
12) comment the page_load event
13) Suppose that the user entered "Zapotec" to the textbox and entered the button.

I want to load the file if it is in the resources.

I really need this.
To netswap:
You wrote:
dim resourceCulture as System.Globalization.CultureInfo
dim str as string = System.Resources.ResourceManager.GetString("EventLogEntryHeaderTemplate", resourceCulture)

When I past it to the designer, I couldn't see the GetString method. Actually, I need a getImage function ;)

SwapnilSoftware ArchitectCommented:
Hi tolgaong,

see following code (taken from hatem72's link, it works)

 make a ResourceManager, as an assembly-ignorant ResourceManager through the
' CreateFileBasedResourceManager method. Simply specify the name of the resources
' file, and the location. The single "." indicates that the current directory should
' be searched the null indicates to use the default resourceset
Dim rm As ResourceManager = CreateFileBasedResourceManager( "Greeting", ".", null)

' having got a reference to the resources, retrieve specific strings...
' Note that the CASE MATTERS
rm.GetStream("Greeting") <-- for image kind of thing
rm.GetString("PasswordException") <-- for text

tolgaongAuthor Commented:
I'm sorry but I really cannot achive to work it. :(
I added the following to the the .vb file that was automatically created for my resource files:

Public Shared ReadOnly Property Image(ByVal ImageName As String) As System.Drawing.Bitmap
                Dim obj As Object = ResourceManager.GetObject(ImageName, resourceCulture)
                Return CType(obj, System.Drawing.Bitmap)
            End Get
End Property

You can then access the images with the following:

YadaYada.Image = my.Resources.NameOfYourResources.Image("NameOfImage")

Good luck, Steve

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tolgaongAuthor Commented:
That's what I'm looking for.

Thanks very much.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.