Hi John
Yes. Think of it in terms of memory space. Your form1 that opens form 2 is
different from the "instance" of form1 you create inside of form2.i.e you
actually have 3 memory spaces in play 2 * Form1's and 1* Form 2.
You actually have 2 instance of form 1 running and the label would be
changed as anticipated but because you haven't shown the second instance
(the form1 instance in form 2) you dont see the change. You could use
shared properties to achieve the result or pass in a reference to form1
from the starting form1 to form2 or cast from me.owner or me.parent
depending on the relationship between form1 and form2 instances.
On button click
Dim frm as new form2(Me)
....Form 2 constructor
Sub New(frm1 as from1)
Me.form1 = frm1
End Sub
A more advanced implementation would be to use events to signal form1 to
change it picture box. This has the advantage of form2 not having to keep
track of a form 1 instead just raising an event in response to some action
that listeners (form1) can the handle.
Richard
"johnb41" <or****@informatik.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I can't believe i'm stumbling on such a seemingly minor task. I have a
major mental block here.
I have boiled down the problem to it's most basic form:
I have form1 and form2. Form1 has a blank label. Form2 has a button.
When clicked, i want to add hard coded text to Form1.
Code for form1: (simply opens up form2)
Private Sub Button1_Click(...) Handles Button1.Click
Dim form2 As New Form2
form2.Show()
End Sub
Code for form2: (writes text to form1)
Dim form1 As New Form1
Private Sub Button1_Click(...) Handles Button1.Click
form1.Label1.Text = "Sample text"
End Sub
Nothing happens! In my real life app, i want to display an image in a
picturebox on a different form from the currently active form.
Help anyone?
Thanks very much!
John