Picture001.BackgroundImage = New Bitmap(My.Resources.Image001) Picture002.BackgroundImage = New Bitmap(My.Resources.Image002) Picture003.BackgroundImage = New Bitmap(My.Resources.Image003) Picture004.BackgroundImage = New Bitmap(My.Resources.Image004) Picture005.BackgroundImage = New Bitmap(My.Resources.Image005)
■No29193 (良碁 さん) に返信
> という処理を100行書いているのですが
> For〜Loopなどを使って処理をかけないでしょうか
>
試してないので、動くか分かりません。
Dim image As Drawing.Bitmap
Dim stream As System.IO.Stream
For i As Integer = 1 To 100
stream = My.Resources.ResourceManager.GetStream("Image" & i.ToString("000"))
image = New Drawing.Bitmap(stream)
DirectCast(Me.Controls("Picture" & i.ToString("000")), PictureBox).BackgroundImage = image
Next
Dim image As Drawing.Bitmap For i As Integer = 1 To 100 image = My.Resources.ResourceManager.GetObject("Image" & i.ToString("000")) DirectCast(Me.Controls("Picture" & i.ToString("000")), PictureBox).BackgroundImage = image Next i