From: M on 27 May 2010 16:34 Hello: I didn't get a chance to test this yet and haven't found a clear answer online. If I have 3 parameters, and I want them all to be passed by value, do I need to specify ByVal 3 separate times like this: Sub subTest(ByVal strParam1, ByVal strParam2, ByVal strParam3), or can I specify ByVal once and have it apply to all parameters, like this: Sub subTest(ByVal strParam1, strParam2, strParam3)? Thank you. -- Regards, M MCTS, MCSA http://SysAdmin-E.com
From: Tom Lavedas on 27 May 2010 16:48 On May 27, 4:34 pm, "M" <m...(a)nowhere.com> wrote: > Hello: > > I didn't get a chance to test this yet and haven't found a clear answer online. > > If I have 3 parameters, and I want them all to be passed by value, do I need to specify ByVal 3 separate times like this: Sub subTest(ByVal strParam1, ByVal strParam2, ByVal strParam3), or can I specify ByVal once and have it apply to all parameters, like this: Sub subTest(ByVal strParam1, strParam2, strParam3)? > > Thank you. > > -- > Regards, > M > MCTS, MCSAhttp://SysAdmin-E.com Three times. _____________________ Tom Lavedas
From: Al Dunbar on 27 May 2010 19:15 "Tom Lavedas" <tglbatch(a)verizon.net> wrote in message news:46213a90-9ee8-4fdc-bb9f-57d3dd9925e3(a)z17g2000vbd.googlegroups.com... > On May 27, 4:34 pm, "M" <m...(a)nowhere.com> wrote: >> Hello: >> >> I didn't get a chance to test this yet and haven't found a clear answer >> online. >> >> If I have 3 parameters, and I want them all to be passed by value, do I >> need to specify ByVal 3 separate times like this: Sub subTest(ByVal >> strParam1, ByVal strParam2, ByVal strParam3), or can I specify ByVal once >> and have it apply to all parameters, like this: Sub subTest(ByVal >> strParam1, strParam2, strParam3)? >> >> Thank you. >> >> -- >> Regards, >> M >> MCTS, MCSAhttp://SysAdmin-E.com > > Three times. Agreed. Also, it appears to be fairly clear here: http://msdn.microsoft.com/en-us/library/x7hbf8fa(VS.85).aspx where it states that: The arglist argument has the following syntax and parts: [ByVal | ByRef] varname[( )] Arguments -------------------------------------------------------------------------------- ByVal Indicates that the argument is passed by value. ByRef Indicates that the argument is passed by reference. If ByVal and ByRef are omitted, the default is ByRef. If these keywords were to apply to subsequent parameters, the syntax would have to be different, and so would the explanation, for example, "the argument", would be given as "the argument plus all following unqualified arguments" /Al
From: Todd Vargo on 28 May 2010 23:49 Al Dunbar wrote: > Tom Lavedas wrote: >> On May 27, 4:34 pm, "M" <m...(a)nowhere.com> wrote: >>> Hello: >>> >>> I didn't get a chance to test this yet and haven't found a clear answer >>> online. >>> >>> If I have 3 parameters, and I want them all to be passed by value, do I >>> need to specify ByVal 3 separate times like this: Sub subTest(ByVal >>> strParam1, ByVal strParam2, ByVal strParam3), or can I specify ByVal >>> once and have it apply to all parameters, like this: Sub subTest(ByVal >>> strParam1, strParam2, strParam3)? >>> >>> Thank you. >>> >>> -- >>> Regards, >>> M >>> MCTS, MCSAhttp://SysAdmin-E.com >> >> Three times. > > Agreed. Also, it appears to be fairly clear here: > > http://msdn.microsoft.com/en-us/library/x7hbf8fa(VS.85).aspx > > where it states that: > > The arglist argument has the following syntax and parts: > > [ByVal | ByRef] varname[( )] > > Arguments > -------------------------------------------------------------------------------- > > ByVal > Indicates that the argument is passed by value. > > ByRef > Indicates that the argument is passed by reference. If ByVal and ByRef > are omitted, the default is ByRef. > > If these keywords were to apply to subsequent parameters, the syntax would > have to be different, and so would the explanation, for example, "the > argument", would be given as "the argument plus all following unqualified > arguments" Of course, OP could have answered their own question with a simple test. var1 = "ByVal" var2 = "ByVal" test var1, var2 msgbox "var1=" & var1 & vbNewline & "var2=" & var2 sub test(ByVal var1, var2) var1 = "ByRef" var2 = "ByRef" end sub -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages)
From: Al Dunbar on 30 May 2010 23:39 "Todd Vargo" <tlvargo(a)sbcglobal.netz> wrote in message news:#APl8nh$KHA.5848(a)TK2MSFTNGP06.phx.gbl... > Al Dunbar wrote: >> Tom Lavedas wrote: >>> On May 27, 4:34 pm, "M" <m...(a)nowhere.com> wrote: >>>> Hello: >>>> >>>> I didn't get a chance to test this yet and haven't found a clear answer >>>> online. >>>> >>>> If I have 3 parameters, and I want them all to be passed by value, do I >>>> need to specify ByVal 3 separate times like this: Sub subTest(ByVal >>>> strParam1, ByVal strParam2, ByVal strParam3), or can I specify ByVal >>>> once and have it apply to all parameters, like this: Sub subTest(ByVal >>>> strParam1, strParam2, strParam3)? >>>> >>>> Thank you. >>>> >>>> -- >>>> Regards, >>>> M >>>> MCTS, MCSAhttp://SysAdmin-E.com >>> >>> Three times. >> >> Agreed. Also, it appears to be fairly clear here: >> >> http://msdn.microsoft.com/en-us/library/x7hbf8fa(VS.85).aspx >> >> where it states that: >> >> The arglist argument has the following syntax and parts: >> >> [ByVal | ByRef] varname[( )] >> >> Arguments >> -------------------------------------------------------------------------------- >> >> ByVal >> Indicates that the argument is passed by value. >> >> ByRef >> Indicates that the argument is passed by reference. If ByVal and ByRef >> are omitted, the default is ByRef. >> >> If these keywords were to apply to subsequent parameters, the syntax >> would have to be different, and so would the explanation, for example, >> "the argument", would be given as "the argument plus all following >> unqualified arguments" > > Of course, OP could have answered their own question with a simple test. Granted - but he said he didn't have time to do that. Funny, though, that he (apparently) did have time for an unsuccessful look "for a clear answer online"! So he got a few answers of "three times" from us. I wonder what his conclusion would have been had someone given a dissenting opinion. /Al > var1 = "ByVal" > var2 = "ByVal" > test var1, var2 > msgbox "var1=" & var1 & vbNewline & "var2=" & var2 > > sub test(ByVal var1, var2) > var1 = "ByRef" > var2 = "ByRef" > end sub > > -- > Todd Vargo > > (Post questions to group only. Remove "z" to email personal messages)
|
Pages: 1 Prev: output to cmd with | symbol Next: Perform OR operation on function return values |