Passing parameters to a form load procedure 
Author Message
 Passing parameters to a form load procedure

I need some help please...

I was wondering how you can pass parameters to a form's load sub procedure
ie.  form_load(byval some parameter)

I can not seem to get this to work

It is either i) not allowed
            ii) I am not calling it right
           iii) ???

I know I can set a global var to the value but I do not want to do it
this way.

Any help is greatly appreciated.

Thanks in advance

Judith



Fri, 25 Jul 1997 21:31:59 GMT  
 Passing parameters to a form load procedure

Quote:

> I was wondering how you can pass parameters to a form's load sub procedure
> ie.  form_load(byval some parameter)

> I can not seem to get this to work

> It is either i) not allowed
>             ii) I am not calling it right
>            iii) ???

It doesn't work..., basically it is not allowed...
Something microsoft should think of for v.4.0...

Quote:
> I know I can set a global var to the value but I do not want to do it
> this way.

This is the only method available at this time... I've tried setting a
form's Tag with info, before it "show'd" itself, but that doesn't work
fast enough.  

Quote:
> Judith

ttyl
Jason


Sat, 26 Jul 1997 05:14:24 GMT  
 Passing parameters to a form load procedure


Quote:


>> I was wondering how you can pass parameters to a form's load sub
procedure
>> ie.  form_load(byval some parameter)

>> I can not seem to get this to work

>> It is either i) not allowed
>>             ii) I am not calling it right
>>            iii) ???

>It doesn't work..., basically it is not allowed...
>Something microsoft should think of for v.4.0...

>> I know I can set a global var to the value but I do not want to do it
>> this way.

>This is the only method available at this time... I've tried setting a
>form's Tag with info, before it "show'd" itself, but that doesn't work
>fast enough.  

Yeah. It is regrettable that MS didn't think this one through very well.
However, I don't think using a global variable is particularly loathsome.
It will only be needed for a brief period of time and can be reused
amongst multiple forms since form loading will generally be an atomic
process.

Setting a form's tag property does indeed appear to be somewhat flaky. It
worked for me until I put a CSFORM.VBX control on my form; this
subclasses the form's window procedure to provide scrolling form
capabilities. At that point, my code broke, because setting the tag
property caused the VBM_SETPROP message to get to the form AFTER the form
was loaded due to the subclassing.

Of course, some really cunning person out there may have a better
solution.



Mon, 28 Jul 1997 04:43:32 GMT  
 Passing parameters to a form load procedure

Quote:
> I need some help please...
> I was wondering how you can pass parameters to a form's load sub procedure
> ie.  form_load(byval some parameter)
> I can not seem to get this to work
> It is either i) not allowed
>             ii) I am not calling it right
>            iii) ???
> I know I can set a global var to the value but I do not want to do it
> this way.
> Any help is greatly appreciated.
> Thanks in advance
> Judith

Sorry, you either have to do it by using global variables or by
setting (possibly hidden) controls on the form. You can't add
your own additional parameters to event procedures or change the
types of existsing parameters.

It's usually better to just use globals and hide the nastiness in
a function or procedure instead of peppering your code with
references to the global variable(s).

--

Systems Mangler/Head Geek/Top Jolt {*filter*}, BFTSI
WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Mon, 28 Jul 1997 06:22:47 GMT  
 Passing parameters to a form load procedure

|> >
|> > I was wondering how you can pass parameters to a form's load sub procedure
|> > ie.  form_load(byval some parameter)
|> >
     [....]
|>
|> > I know I can set a global var to the value but I do not want to do it
|> > this way.
|>
|> This is the only method available at this time... I've tried setting a
|> form's Tag with info, before it "show'd" itself, but that doesn't work
|> fast enough.  

I used the method you described. Pass the parameter in Form's tag. In Form_load
do nothing, in Form_activate do the initialization when tag is not NULL, after
initialization clear the tag. In this way the form actually shows faster, but
if your initialization invloves moving controls around then this may cause
flashing.

At the end I used a global variable!

Cheers.

---------------------
DAMTP, Cambridge, UK.
Atta Chui.



Mon, 28 Jul 1997 18:55:16 GMT  
 Passing parameters to a form load procedure
X-Newsreader: WinVN 0.91.4


(Atta Chui) says:

Quote:




>|> >
[snip]

>I used the method you described. Pass the parameter in Form's tag. In
Form_load
>do nothing, in Form_activate do the initialization when tag is not NULL,
after
>initialization clear the tag. In this way the form actually shows
faster, but
>if your initialization invloves moving controls around then this may
cause
>flashing.

>At the end I used a global variable!

Using the tag property is not reliable if the form is subclassed e.g with
a scrolling form control like CSFORM.VBX.

To prevent flashing, set the form's design-time top and left to
-20000,-20000; load the form, get it totally ready then use the move
method to bring it onto the screen.



Tue, 29 Jul 1997 04:35:58 GMT  
 Passing parameters to a form load procedure

Quote:
>I need some help please...

>I was wondering how you can pass parameters to a form's load sub procedure
>ie.  form_load(byval some parameter)

>I know I can set a global var to the value but I do not want to do it
>this way.

>Any help is greatly appreciated.

>Thanks in advance

>Judith

The best thing that I have found to do is call a subroutine that loads the form
as part of it process. i.e. you want to open form X and you want to pass it
an string NAME.  Create a sub such that

Sub Sample ( name as string)
        FormX.Hide ' loads the form without showing it
        FormX.Text1 = name ' set your values
        FormX.Show ' show the form
End Sub

Hope this helps

James E. Scheid



Thu, 31 Jul 1997 12:49:06 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Passing a Form as a parameter to a stored procedure

2. Control Arrays, Procedure Parameters & Load

3. Passing Parameters to Store Procedures

4. Passing a parameter to a stored procedure from VBA

5. Passing parameter to Stored Procedures from VB

6. passing custom objects as parameters to procedures

7. Passing custom class objects as parameters to procedures

8. Passing parameters to stored procedures - help please!

9. How can i pass the parameters of the type IMAGE to the stored Procedure

10. Pass parameter to Sub Main() procedure

11. Passing parameters from Excel to SQL 6.5 stored procedures

12. Passing parameter to Sybase ASA Stored procedure via ADO

 

 
Powered by phpBB® Forum Software