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
Printable View
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
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.
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.
Oh and my VB version is 9782 :)