My.Resources.ResourceManager.GetObject("resource name")
文字列でリソースを読み取るために使用できます。文字列名と画像オブジェクト自体の両方を含む、リソースからすべての埋め込み画像のリストを取得する方法を示すコード例を次に示します。
Public Class EmbeddedImage
Public Sub New(ByVal name As String, ByVal image As Image)
_name = name
_image = image
End Sub
Public ReadOnly Property Name() As String
Get
Return _name
End Get
End Property
Private _name As String
Public ReadOnly Property Image() As Image
Get
Return _image
End Get
End Property
Private _image As Image
End Class
Private Function getEmbeddedImages() As List(Of EmbeddedImage)
Dim images As List(Of EmbeddedImage) = New List(Of EmbeddedImage)()
Dim resources As ResourceSet = My.Resources.ResourceManager.GetResourceSet(CultureInfo.CurrentCulture, True, True)
For Each resource As DictionaryEntry In resources
If TypeOf resource.Value Is Image Then
images.Add(New EmbeddedImage(resource.Key.ToString(), CType(resource.Value, Image)))
End If
Next
Return images
End Function