Solved

VB.Net Working with My.Resources dynamically

Posted on 2010-08-24
3
679 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
Comment Utility
       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
Comment Utility
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
Comment Utility
My solution did exactly what i needed to do as per the OP and my comment.
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

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 …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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