Q: forms

  • Thread starter Thread starter Geoff Jones
  • Start date Start date
G

Geoff Jones

Hi

I have a form (form A) which displays another form (form B). Is there a way,
from formB to see events/variables in formA whilst formB is displayed?

Geoff
 
Geoff Jones said:
I have a form (form A) which displays another form (form B). Is there a
way, from formB to see events/variables in formA whilst formB is
displayed?

Pass a reference pointing to form A to your instance of form B. You can do
this in a property or a method parameter, for example.
 
Hi Herfried

Could you give me some example code to do so via a property?

Thanks in advance

Geoff
 
Inside FormB, alter the constructor to take a reference to FormA:

'*** FormB ***
Private _formA As FormA

Public Sub New(parentform As FormA)
_formA = parentform
End Sub


Then inside FormA when you show FormB you would call it like this (for
example from a button click):

Dim frmB As New FormB(Me)

Notice that Me refers to FormA and it is passed into FormB. From
inside form B you can use the private variable to access all the
properties/methods of FormA.

HTH

Chris
 
Just to add something to Chris's post, if you also want the events declare
the form with withevents
Private _formA As FormA 'no events
Private withevents _formA as FormA 'withe events

Hth Greetz Peter
 
Many thanks Everybody

Geoff

Peter Proost said:
Just to add something to Chris's post, if you also want the events declare
the form with withevents

Private withevents _formA as FormA 'withe events

Hth Greetz Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top