Results 1 to 4 of 4

Thread: [RESOLVED] Passing (xxx) = ByVal?

  1. #1

    Thread Starter
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Resolved [RESOLVED] Passing (xxx) = ByVal?

    I read somewhere that enclosing a function parameter in parentheses forces it to be passed ByVal. However I also had the idea from somewhere that this was removed from VB 6, or a SP for it, or something. I have 6 SP6, does it still apply?

    Cheers

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Passing (xxx) = ByVal?

    I can't even remember if I installed SP 6, I am pretty sure I did though. How do I tell, according to Help About my Version = 8176 VBA: Retail = 6.0.8169?

    Anyways, a quick test shows the parameter is passed ByVal.

    I really doubt that MS would change this functionality.

  3. #3

    Thread Starter
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Passing (xxx) = ByVal?

    Thanks.

    I found out why; if you use the brackets, it seems to treat it as an expression rather than a direct reference.

    This proves it:
    VB Code:
    1. Dim lTest As Long
    2. lTest = 100
    3. Debug.Print VarPtr(lTest)
    4. Debug.Print VarPtr((lTest))

    (lTest) has a different pointer than lTest which indicates that the parentheses force VB to make a temporary variable.

  4. #4

    Thread Starter
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] Passing (xxx) = ByVal?

    Oh and my VB version is 9782

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