Passing arguments from one form to another 
Author Message
 Passing arguments from one form to another

Hi,
How can I pass a varaiable from one form to another?

  Amit



Fri, 21 Nov 2003 23:31:13 GMT  
 Passing arguments from one form to another
Hello Amit

    X= FormA.SomeVariable

Sukesh


Quote:
> Hi,
> How can I pass a varaiable from one form to another?

>   Amit



Fri, 21 Nov 2003 23:59:53 GMT  
 Passing arguments from one form to another
FORM1.TEXT1.TEXT=FORM2.TEXT2
I think u are looking for .

Shahid


Quote:
> Hello Amit

>     X= FormA.SomeVariable

> Sukesh



> > Hi,
> > How can I pass a varaiable from one form to another?

> >   Amit



Sat, 22 Nov 2003 01:09:12 GMT  
 Passing arguments from one form to another
I can't speak for Sukesh, but the form of his example
is perfectly acceptable.  Moreover, it's more respectful
of the concept of encapsulation.

If you need to get or put information to a form, you
shouldn't have to know about it's internal construction--
ie, that there's a text box named Text1.

Instead, create public property to retrieve and put
values.  Here's a brief example of interacting with
a hypothetical BrowseForFolder form.  (There are
other alternatives, but this makes a decent illustration.)

'calling form

Private Sub cmdPathBrowse_Click()
  Dim oBrowse as frmBrowseForFolder

  'create a new browse for folder form
  Set oBrowse = New frmBrowseForFolder

  'tell it what directory to begin in
  oBrowse.SelectedPath = txtPath.Text

  'allow the user to select
  oBrowse.Show vbModal

  'was something selected?
  If Not oBrowse.Cancel Then
    txtPath.Text = oBrowse.SelectedPath
  End If

  'clean up--technically not required, but good practice
   Set oBrowse = Nothing
End Sub

In the frmBrowseForFolder form, you would define
Property Get/Let procedures for SelectedPath, and
a Property Get procedure for Cancel.

Because you've abstracted the intraction between these
forms, you can implement the details in any manner that
you choose--you don't even need to have a SelectedPath
variable.


Quote:
> FORM1.TEXT1.TEXT=FORM2.TEXT2
> I think u are looking for .

> Shahid



> > Hello Amit

> >     X= FormA.SomeVariable

> > Sukesh



> > > Hi,
> > > How can I pass a varaiable from one form to another?

> > >   Amit



Sat, 22 Nov 2003 04:42:06 GMT  
 Passing arguments from one form to another
Hi

I prefer to use   X= FormA.SomeVariable, where may be SomeVariable
=txtBox.Text or whatever

Later if it is more convenient to pick this value from another control  or
one replaces the original control , one has to only change the code  in the
source form. Otherwise, if referencing this from a control and the data is
required in n number of forms,  one sits down to change the code in all the
forms. Rather inconvenient,  I must say.

While coding, I always remember to KISS (Keep It Simple, Stupid)

Sukesh



Sat, 22 Nov 2003 13:25:12 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. passing arguments from one form to another

2. Passing one dimension of a variant table as argument of a function

3. Pass argument but only one instance running

4. How to pass one record from a recordset as an argument

5. One instance passing arguments to another

6. How do you pass from obj from one form to a module/forms

7. Arguments : Passing Arguments containing <">

8. Newbie, correct syntax passing arguments as form names

9. Passing form field type constant as an argument

10. passing a form as argument not working !

11. Passing arguments to new forms

12. Passing arguments to forms

 

 
Powered by phpBB® Forum Software