I am working with multiple forms and a means of refreshing their contents.
I have a subroutine that works just fine opening the forms, adding a PictureBox control to it and attaching and image to picture box and finally showing the form, although sometimes there's a lag between the form framework appearing and the image filing the frame.
I have another subroutine dedicated to changing the image in the form on command. The problem is that my code generates copies of the original windows...and I just want to change the image going into the picturebox. Somehow VB.net is treating my variables here as local despite every effort I can make to have them be global. Every time I try to pull separate DIM statements and control initiation statement from the code I get "uninitialized local variable" error messages.
Carney's VB.net for complete beginners says that by moving the DIM statements to the top of the form1.vb, above the first subroutine, in the FORM1 Class section, you can avoid this problem. I've tried this but it doesn't seem to work.
So here's the code I'm working with. I either need to be able to re-use the form/picture box, or destroy it and open a new one in it's place, former preferred.
Select Case i Case 1 MForm1.Close() Dim MForm1 As New Form2 MForm1.Location = New Point(xloc1, yloc1) MForm1.Name = "Form 1" MForm1.Size = New Size(xsize, ysize) Dim PictureBox1 As New PictureBox MForm1.Controls.Add(PictureBox1) With PictureBox1 .Image = Image.FromFile(CurrentPic(i)) MsgBox(CurrentPic(i)) End With MForm1.Show()
Thanks!