By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,696 Members | 1,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,696 IT Pros & Developers. It's quick & easy.

copy or reference

P: n/a
Hello,

when I return an object from a function, get I a copy or a reference to the
calling function?

function AnyFunction as MyClass
dim objectOfMyClass as MyClass
....
return objectOfMyClass
end function

objectOfCall = AnyFunction 'copy or reference?

I think a copy, but I am not sure.

Albert Krüger
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Kruger,

With "object" types forever a reference.

Passing byval means passing the reference for those types. I assume that
because of your question that can give as well a misunderstanding for you.

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
"Albert Krüger" <al************@mhp-net.de> schrieb:
when I return an object from a function, get I a copy or a reference to
the
calling function?

function AnyFunction as MyClass
dim objectOfMyClass as MyClass
...
return objectOfMyClass
end function

objectOfCall = AnyFunction 'copy or reference?

I think a copy, but I am not sure.


If 'MyClass' is a reference type (class), the function will return a
reference, otherwise (value type, structure) it will return a "copy".

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.