Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Assignment by reference or value

Hi NG

I have a question about assignment of variables by reference or value.

I have a module where a collection C is defined as public.

In my form i want to use that information. Because i use a callback e.g.
button_click() i can not parse C in to the function. Instead i do the
following in the button_click() callback

dim A as collection
A = modSomething.C

Is A then a copy of C or is it a reference?
For performance reasons i would like it to be a reference.

Regards
Mark


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Assignment by reference or value

Mark,

As far as I can tell from your description, A is neither a copy nor a
reference. It is not a copy as it will hold different data than C, and it is
not a reference as it is a new object in it's own right. It will have a
similar structure as C, being a collection, but will occupy a separate chunk
of memory, and this may be what you mean by copy.

I accept that you cannot pass C to the Button_Click event, but as it is a
public variable it is accessible within the form code, as you show, which
means that if you are happy changing it there, you do not need A.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark" wrote in message
...
Hi NG

I have a question about assignment of variables by reference or value.

I have a module where a collection C is defined as public.

In my form i want to use that information. Because i use a callback e.g.
button_click() i can not parse C in to the function. Instead i do the
following in the button_click() callback

dim A as collection
A = modSomething.C

Is A then a copy of C or is it a reference?
For performance reasons i would like it to be a reference.

Regards
Mark




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Assignment by reference or value

Thanks! I should then use the WIDTH keyword





"Bob Phillips" wrote in message
...
Mark,

As far as I can tell from your description, A is neither a copy nor a
reference. It is not a copy as it will hold different data than C, and it

is
not a reference as it is a new object in it's own right. It will have a
similar structure as C, being a collection, but will occupy a separate

chunk
of memory, and this may be what you mean by copy.

I accept that you cannot pass C to the Button_Click event, but as it is a
public variable it is accessible within the form code, as you show, which
means that if you are happy changing it there, you do not need A.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark" wrote in message
...
Hi NG

I have a question about assignment of variables by reference or value.

I have a module where a collection C is defined as public.

In my form i want to use that information. Because i use a callback e.g.
button_click() i can not parse C in to the function. Instead i do the
following in the button_click() callback

dim A as collection
A = modSomething.C

Is A then a copy of C or is it a reference?
For performance reasons i would like it to be a reference.

Regards
Mark






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Assignment by reference or value

Mark,

Sorry, but I do not understand that comment.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark" wrote in message
...
Thanks! I should then use the WIDTH keyword





"Bob Phillips" wrote in message
...
Mark,

As far as I can tell from your description, A is neither a copy nor a
reference. It is not a copy as it will hold different data than C, and

it
is
not a reference as it is a new object in it's own right. It will have a
similar structure as C, being a collection, but will occupy a separate

chunk
of memory, and this may be what you mean by copy.

I accept that you cannot pass C to the Button_Click event, but as it is

a
public variable it is accessible within the form code, as you show,

which
means that if you are happy changing it there, you do not need A.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default Assignment by reference or value

Bob, I not sure that's right. My understanding is that A is a
reference (pointer) to C. A isn't a new Collection object in its own
right because it hasn't been instantiated. Rather it will just hold
the address in memory of C. Hence A *will* hold the same data as C.
Jamie.

--

"Bob Phillips" wrote in message ...
Mark,

As far as I can tell from your description, A is neither a copy nor a
reference. It is not a copy as it will hold different data than C, and it is
not a reference as it is a new object in it's own right. It will have a
similar structure as C, being a collection, but will occupy a separate chunk
of memory, and this may be what you mean by copy.


"Mark" wrote in message
...
Hi NG

I have a question about assignment of variables by reference or value.

I have a module where a collection C is defined as public.

In my form i want to use that information. Because i use a callback e.g.
button_click() i can not parse C in to the function. Instead i do the
following in the button_click() callback

dim A as collection
A = modSomething.C

Is A then a copy of C or is it a reference?
For performance reasons i would like it to be a reference.

Regards
Mark




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Assignment by reference or value

I guess I saw New where there wasn't one. But, I just, and it even seems to
be the case when you New A(?).

I admit to being confused by what I am seeing, so it back to the books
methinks ( Curland's)

Bob


"onedaywhen" wrote in message
om...
Bob, I not sure that's right. My understanding is that A is a
reference (pointer) to C. A isn't a new Collection object in its own
right because it hasn't been instantiated. Rather it will just hold
the address in memory of C. Hence A *will* hold the same data as C.
Jamie.

--



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel assignment Trish Excel Discussion (Misc queries) 0 October 14th 08 04:44 AM
point assignment Blah Excel Discussion (Misc queries) 4 July 21st 06 12:29 AM
Key Assignment Log Norma Excel Discussion (Misc queries) 0 May 12th 05 04:10 PM
assignment problem L. Chung Excel Worksheet Functions 1 April 17th 05 06:06 AM
excel assignment Davko Excel Discussion (Misc queries) 1 April 15th 05 08:32 AM


All times are GMT +1. The time now is 05:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"