Whats the best class way to do this

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

Hi,

I have an app with three forms.

a) Master form. It has a grid with a list of contact names on it.
b) Contact form. This form is where you can edit/create a new contact
c) address form. This form is a popup launch from the contact form to enter
the contacts address.

I have created a basic class for the contact object. What I want to do, is
to only create the class when I load the contact form, and then destroy it
when I close that form. My problem is that if I create the class within form
b, then when the user, uses form c to enter the contact details, they will
not be able to access the class, as it is link to form b.

How is the best way to get the address details in form c, into the class
living in form b?

Hope that makes sense!
 
Hi Aussie,

I think you can use a dialogform
Rough written
\\\\
In formB
dim frmC as new formC
frmC.showdialog(me)
adresInB = frmC.adres
nameInB=frmC.name
etc
frmC.dispose
////
frmC.adres ietc are either a public read only properties in formC or a
public variables in formC that is what you wish.

I hope this was the meaning?
Cor
 
news.microsoft.com said:
How is the best way to get the address details in form c, into the class
living in form b?

You should be able to add a reference to the object in FormC and simply
assign that reference from FormB (which I assume creates the form) just
before it displays the pop-up form.
 
Hi News.ms,

This is one of those order a hundred cats - we're going skinning issues.
So here's another method. ;-)

In this one, Form C provides a function which does the showing and returns
a value. This simpifies the calling from the originating Form (B). It also
allows Form C to be called from other Forms without knowing anything about
them. All that's required is that Form B knows about the ShowAndTell method.

Class FormC
Public Function ShowAndTell As SomeResultType
Me.ShowDialog
Dim oResult As SomeResultType
oResult.This = SomeValue
oResult.That = SomeOtherValue
Return oResult
End Sub

In FormB
Dim frmC As new FormC
Dim oResult As SomeResultType = frmC.ShowAndTell
'oResult now contains juicy goodies.

Regards,
Fergus
 
Back
Top