Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Location
    India
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing a parameter by reference

    It's been a while since I worked with ASP, I've forgotten some concepts. I know vb (and hence vbscript) passes arguments by reference. The following page gave me 100, I expected 1000:

    Code:
    <%
    Dim a
    
    a = 10
    
    call test1(a)
    
    Response.Write a
    
    Sub test1(b)
    	b = 100
    	test2(b)
    End Sub
    
    Sub test2(c)
    	c = 1000
    End Sub
    %>
    Why's that test2(b) did not change the value of b in test1? Is it because parameter variables are not passed by reference?

    Thanks.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Victoria, BC, Canada
    Posts
    962
    Thanks
    0
    Thanked 1 Time in 1 Post
    I think VB and VBScript actually pass by value...I may be wrong though.

    However, just to be sure, try adding "ByRef" in front of the appropriate paraemter in your parameter lists.


  •  

    Posting Permissions

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