- differences between jet and odbc
- sugarcrm not inserting email
- select random records from access
- button click event firing twice
- how to send an email using cdosys
- installing perl on win2003 64 bit
- asp.net page event order
- rewrite rule for subdomains only
- extra items in javascript array
- IE7 margin auto not working
- IE7 border style dotted glitch
- ByRef and ByVal in vbscript
- weather rss feed
- Classic asp crib sheet
- Firefox onsubmit image change
- limit records in access
- AccessDataSource is thick
- double margins in IE6
- extra image padding in html emails
- decimal places in linux flash player
- broken emails in outlook 2007
- double spaced IE list items
- cannot remove movieclip
articles:
ByRef and ByVal in vbscript
Here is an interesting post by Eric Lippert explaining how to pass variables to vbscript subroutines and functions without using ByRef or ByVal:
Sub Bar(x)
End Sub
Sub Baz(a, b)
End Sub
Function Foo(y)
End Function
z = 123
n = Foo(z) ' legal, passes z by reference
n = Foo((z)) ' legal, passes z by reference
'n = Foo z ' illegal, parens required
Foo z ' legal, passes z by reference
Foo(z) ' legal, passes z by value
'Call Foo z ' illegal, parens required
Call Foo(z) ' legal, passes z by reference
Call Foo((z)) ' legal, passes z by value
'n = Bar(z) ' illegal, bar is not a function
Bar z ' legal, passes z by reference
Bar(z) ' legal, passes z by value
Call Bar(z) ' legal, passes z by reference
Call Bar((z)) ' legal, passes z by value
Baz z, z ' legal, passes z by reference
Baz (z), (z) ' legal, passes z by reference
'Baz(z,z) ' illegal, can't use parens
Call Baz(z, z) ' legal, passes z by reference
Call Baz((z), (z)) ' legal, passes z by value
'Call Baz z, z ' illegal, parens required
So basically if you want to pass a variable by value you need to wrap it in an extra set of brackets
Sub Bar(x)
End Sub
Sub Baz(a, b)
End Sub
Function Foo(y)
End Function
z = 123
n = Foo(z) ' legal, passes z by reference
n = Foo((z)) ' legal, passes z by reference
'n = Foo z ' illegal, parens required
Foo z ' legal, passes z by reference
Foo(z) ' legal, passes z by value
'Call Foo z ' illegal, parens required
Call Foo(z) ' legal, passes z by reference
Call Foo((z)) ' legal, passes z by value
'n = Bar(z) ' illegal, bar is not a function
Bar z ' legal, passes z by reference
Bar(z) ' legal, passes z by value
Call Bar(z) ' legal, passes z by reference
Call Bar((z)) ' legal, passes z by value
Baz z, z ' legal, passes z by reference
Baz (z), (z) ' legal, passes z by reference
'Baz(z,z) ' illegal, can't use parens
Call Baz(z, z) ' legal, passes z by reference
Call Baz((z), (z)) ' legal, passes z by value
'Call Baz z, z ' illegal, parens required
So basically if you want to pass a variable by value you need to wrap it in an extra set of brackets