|
-
Jul 26th, 2005, 09:42 AM
#1
[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
-
Jul 26th, 2005, 09:58 AM
#2
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.
-
Jul 26th, 2005, 10:05 AM
#3
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:
Dim lTest As Long
lTest = 100
Debug.Print VarPtr(lTest)
Debug.Print VarPtr((lTest))
(lTest) has a different pointer than lTest which indicates that the parentheses force VB to make a temporary variable.
-
Jul 26th, 2005, 10:08 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|