Solved

VB.Net Working with My.Resources dynamically

Posted on 2010-08-24
3
684 Views
Last Modified: 2012-05-10
Hi Experts,

I'm trying to dynamically work with resource files.
I have created a resource file 'Audio' and added several mp3 files to it.

Normally I would access them via My.Resources.Audio.File1, however I would like to access them based on a combobox's text.

I tried CallByName(), but i cannot get that to work.  

Any suggestions on getting this working?
0
Comment
Question by:sgaggerj
  • 2
3 Comments
 
LVL 17

Assisted Solution

by:Zhaolai
Zhaolai earned 200 total points
ID: 33512413
       Dim o As Object
        Select Case ComboBox1.SelectedIndex
            Case 0
                o = My.Resources.Audio.File1
            Case 1
                o = My.Resources.Audio.File2
             Case 2
                o = My.Resources.Audio.File3
              ......
        End Select


0
 
LVL 1

Accepted Solution

by:
sgaggerj earned 0 total points
ID: 33513204
That's not really dynamically (or at least what i think of as "dynamic").

Here's what i came up with

Dim audio_library As My.Resources.Audio = New My.Resources.Audio
Dim audio() As Byte = audio_library.ResourceManager.GetObject(GameNamesList.Text)

It seems to work, anyone have any negatives against using that?
0
 
LVL 1

Author Closing Comment

by:sgaggerj
ID: 37126819
My solution did exactly what i needed to do as per the OP and my comment.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

11 Experts available now in Live!

Get 1:1 Help Now