Two things:
One, I bet your PictureBoxes haven't actually been instantiated yet. This might cause problems because this code assumes that they've already been instantiated.
Two, You need to cast the result of the GetField stuff to a PictureBox. I'm sorry, I don't remember the VB syntax for casting.
~~Bonnie
>>Basically, you'd need to do something like this (I don't know what your controls are that contain the .Image property, so I'm just calling them object here. You can substitute the correct control:
>>
>> For lnCounter = 1 To lnNumberOfServer
>> MyObject = (object)this.GetType().GetField(MyImageName+lnCounter.ToString().Trim(), BindingFlags.Instance|BindingFlags.NonPublic).GetValue(this);
>> MyObject.Image = Image.FromFile(lcStartupDirectory + "..\Images\Green.gif")
>> Next
>>
>
>There is a small syntax issue here. My image controls are WebServerImage1, WebServerImage2, etc. So far, I have adjusted the code to this:
>
>
> Dim loImage As PictureBox
> For lnCounter = 1 To lnNumberOfServer
> loImage = Me.GetType.GetField("WebServerImage" + lnCounter.ToString().Trim(), _
> Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic).GetValue(Me)
> loImage.Image = ImageList.Images(0)
> Next
>
This provides a Object reference not set to an instance of an object error.