Rob Coll

I know this is probably a very bad way of doing things but I've been forced down a certain path. I have a lot (read: loads!) of embedded images, is there a way to dynamically refer to them

For example, at tht moment I can chuck loads of these into a select case statement:

objImage = My.Resources.screen_1

objImage = My.Resources.screen_2

...

Ideally though, I'd like to be able to construct the My.Resources bit myself, so the number at the end can be generated seperately. Is this possible



Re: Visual Basic Express Edition Embedded Images

nobugz

You could store the resource bitmap references in an array at startup. Retrieving them later is now a simple array index. For example:

Public Class Form1
Private Const SCREENS As Integer = 3
Private mScreens() As Bitmap
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReDim mScreens(SCREENS - 1)
For ix As Integer = 0 To SCREENS - 1
mScreens(ix) = CType(My.Resources.ResourceManager.GetObject("Screen_" + CStr(ix + 1)), Bitmap)
Next
End Sub
End Class






Re: Visual Basic Express Edition Embedded Images

Rob Coll

Ace! Thanks!

Gives me something to do at work tomorrow (other then avoiding work).