Passing Subs as Parameters to other Subs?

Results 1 to 5 of 5

Thread: Passing Subs as Parameters to other Subs?

  1. #1
    Daniel Newman Guest

    Default Passing Subs as Parameters to other Subs?

    I don&#039;t know if this is possible, but I&#039;ve had one of those, last minute tweaks that always cause more problems than they&#039;re worth.<BR><BR>I had one procedure doing it&#039;s thing, and then being followed by another procedure. but now the client wants the second procedures results to be further up the page, which means being within the first procedure! So, unless I hack it all up into many little calls, which it essentially is anyway but I have a couple of controlling Subs, can I do the following:<BR><BR>Call Sub1(value1, value2, value3, Sub2(value1, value2))<BR><BR>Which could also become:<BR><BR>Call Sub1(value1, value2, value3, Sub3(value1, value2, value5))<BR><BR>It does work in the above manner, but is there another way of doing it? I&#039;ve read that you can just pass the Sub direct (without the parameters), but that would mean then having lots of spare params in my first sub, just in case I chose to use them.<BR><BR>Hope this is clear enough. If you need any more info, just ask.<BR><BR>Thanks for your help,<BR>Daniel Newman.

  2. #2
    Miek Guest

    Default RE: Passing Subs as Parameters to other Subs?

    Have your first sub call the second sub... Be sure that the first sub receives all of your variables to pass to the second...<BR><BR>sub first()<BR>call sub2()<BR>end sub<BR><BR>sub sub2()<BR>end sub

  3. #3
    Daniel Newman Guest

    Default RE: Passing Subs as Parameters to other Subs?

    Sorry Miek, but it&#039;s a bit more tricky than that.<BR><BR>I&#039;ll go back to my first example:<BR><BR>Call FirstSub(value1, value2, value3, SecondSub(value1, value2)) <BR><BR>Which could also become: <BR><BR>Call FirstSub(value1, value2, value3, ThirdSub(value1, value2, value5)) <BR><BR>These two calls are very different, and the only real way to fix it would be to have the following fixed parameters for FirstSub:<BR><BR>strValue1, strValue2, strValue3, strSub, strSubValue1, strSubValue2, strSubValue3<BR><BR>You can see how messy that&#039;s already getting? Especially if my chosen Sub needs ten parameters, and I&#039;m passing twenty to the first sub....<BR><BR>Anyone else got any ideas?<BR><BR>Thanks,<BR>Daniel.<BR>

  4. #4
    <eop. Guest

    Default Yuck... That sucks.. Sorry.


  5. #5
    Daniel Newman Guest

    Default I know... but I can't seem to fix it any othe


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts