Let's say I have form1 and form2. Form1 and Form2 are open. You click a button on Form2 and it adds 1 to a variable called myNumber on Form1.
Now the problem is I can't use the new keyword and create a new instance of Form1, because Form1 declares myNumber setting it to 0 on creation of the form. If myNumber gets set to 0 again then all the 1's that were added to that variable were added for nothing....
How do I pass a variable from Form2 to Form1 without creating a new instance of Form1?
Sam HobbsPosted Aug 6, 2010, 5:57 PM
You said "pass a variable from Form2 to Form1"; if my answer won't work then you need to clarify your question, not criticize my attempt to help.
I think you don't understand what is meant by "a public member"; why do you say it won't work?
Noah NUPosted Aug 6, 2010, 2:52 PM
So again back to my question.
Sam HobbsPosted Apr 11, 2010, 11:45 PM
Just create a public member in Form2 and after creating an insance of Form2 but before showing it, set the public member to the value to be passed. In the Form2 load event, use the public member.