Re: sub or function
"CJM" <cjmnews04@news group.nospam> wrote in message
news:%230eGH7Mm FHA.3312@tk2msf tngp13.phx.gbl. ..
:
: "Roland Hall" <nobody@nowhere > wrote in message
: news:OZjYjXHmFH A.2180@TK2MSFTN GP15.phx.gbl...
: >
: > Are you saying a passed variable to a sub, if the value changes will
: > change
: > the value of a global variable? Isn't that only true if it's passed
: > ByRef?
:
: However, if you were talking about a Global variable, there would be no
: reason to pass it as a parameter because it already accessible because it
: is...er.. Global!
:
: I hope this hasn't muddied the water any further!
No problem.
What if it is passed from another sub/function?
function myincfunc(x)
myincfunc= x + 1
end function
sub tomorrow(x)
dim thisday, nextday
thisday = x
nextday = myincfunc(thisd ay)
Response.Write "Tomorrow's secret number is: " & nextday
end sub
dim x
x = 4
tomorrow x
x is global
sub x is byRef, assigned byVal to thisday, passed byRef to func x,
incremented and returned
Did any initial variables change?
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
"CJM" <cjmnews04@news group.nospam> wrote in message
news:%230eGH7Mm FHA.3312@tk2msf tngp13.phx.gbl. ..
:
: "Roland Hall" <nobody@nowhere > wrote in message
: news:OZjYjXHmFH A.2180@TK2MSFTN GP15.phx.gbl...
: >
: > Are you saying a passed variable to a sub, if the value changes will
: > change
: > the value of a global variable? Isn't that only true if it's passed
: > ByRef?
:
: However, if you were talking about a Global variable, there would be no
: reason to pass it as a parameter because it already accessible because it
: is...er.. Global!
:
: I hope this hasn't muddied the water any further!
No problem.
What if it is passed from another sub/function?
function myincfunc(x)
myincfunc= x + 1
end function
sub tomorrow(x)
dim thisday, nextday
thisday = x
nextday = myincfunc(thisd ay)
Response.Write "Tomorrow's secret number is: " & nextday
end sub
dim x
x = 4
tomorrow x
x is global
sub x is byRef, assigned byVal to thisday, passed byRef to func x,
incremented and returned
Did any initial variables change?
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Comment