Okay, this has got me freaked out, as I didn't think this could happen:
I expect Sub FirstSub to print "27", but it prints "32". How can this be??? I thought a Sub would only perform a task, NOT return a value? All the years I have been programming, I have assumed that sending a value to a Sub was a "one way" thing.... Have I just had it wrong all these years??? Can somebody please explain this to me???
Is it something to do with the way I have the variables scoped?
I expect Sub FirstSub to print "27", but it prints "32". How can this be??? I thought a Sub would only perform a task, NOT return a value? All the years I have been programming, I have assumed that sending a value to a Sub was a "one way" thing.... Have I just had it wrong all these years??? Can somebody please explain this to me???
Is it something to do with the way I have the variables scoped?
Sub FirstSub
dim x as integer
x=27
SecondSub x
debug.print x
end sub
Sub SecondSub(n as integer)
n=n+5
end sub
Last edited: