Results 1 to 2 of 2

Thread: Call to a procedure which is the same one as it is currently in

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Location
    Baexem, Limburg, The Netherlands
    Posts
    5

    Post

    Hello,

    I got a problem.

    I have a sub2(i,n) which consists of a For Next statement.

    sub2(i,n)
    For l(i)=1 to n
    .......
    ......
    i=i+1
    n=n-1
    Call sub2(i,n)
    Next
    End sub

    So i get nested for next loops.

    So when it has called all the same subs within sub2 he has to loop through all those for next statements.

    The problem is that it doesn't use the corresponding i and n in the different loops anymore which I passed as value. Instead he uses the last values passed.

    How can i tackle this?

    Any help greatly appreciated...

    Kind regards,

    Gertjan Oonk

  2. #2
    Junior Member
    Join Date
    Feb 2000
    Posts
    21

    Post

    If I understand you well, you want your i and n values to be passed by value. VB receives parameters by reference by default.

    There is two way to force VB to pass parameters by value:

    sub2(ByVal i, ByVal n)

    or on the call

    Call sub2 (i), (n)

    Hope it will help...

Posting Permissions

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



Click Here to Expand Forum to Full Width