Hi
_ . I deeply apologise for any confusion but I have changed my Opinion. IMVHO “...
you can pass an Array by Value.....”
_. I will attempt to explain. I fully expect I am wrong due to some subtle deep down thing that is going on in VBA and would be very happy for anyone to set me straight. Until then, this is my Story and i am sticking to it.
The Story.
_. Imagine an Imaginary World.
General Description of this world:
_. In this World there is a large Island called ApplicationOfEngland. Close by there is a smaller Island called The Isle of CallableProcedures.
_. There are two Ferries serving the two Islands which share the same Ports and sail in parallel routes. One is called
shigByRef
and the other
shigByVal
_. There is one main Road leading to and from the Ports. So effectively the Ferries are used to connect the two Ports. That is to say, the Ferries serve as to transport to and from the Island. There is a Control Point and a Junction at each Port Entry. The purpose of the Control Point is to Determine which Ferry will be used.
_. There is, amongst other things, an interesting special form of transport in our Imaginary World. It is something we might imagine to be a very large “Smart” Bus. - Noting there are concepts here in the imaginary World beyond our understanding,...( like in VBA )..!..., - This Bus, called
Variant has the interesting characteristic that you can just about accommodate anything and do anything in it. ( You could even put ApplicationOfEngland Init ..( and maybe the entire World ! )
_...................................
_. There are various Laws ( of Nature and Government ) governing our Imaginary World.
_. Law 1. Cloning
. It is possible to clone all Things and Peoples, that is to say make a perfect copy. This can be done very quickly and a large amount of times. This cloning is generally controlled by the Port Authorities.
_. Law 2. Residence
_2a) In ApplicationOfEngland Many Things and people may exist and reside.
_2b) In Isle of CallableProcedures no residence is allowed. However Things, People and a large amount of Clones may visit for short periods of time, provided they use the Ferries to and from The Isle of CallableProcedures
_. Law 3. Port Controls and Visiting of The Isle of CallableProcedures
_3a) Anyone or Thing wishing to visit The Isle of CallableProcedures must use the Main roads and Ferries. They should also expect and accept to be controlled at least once at a Port.
_3b) It is required that anyone or Thing wishing to visit The Isle of CallableProcedures is labelled either with
ByVal or
ByRef. Should anyone arrive at the Port Control in ApplicationOfEngland with no label, they will be given the label
ByRef at the Port in ApplicationOfEngland.
_3c) You can probably start to guess what happens at the Port Control in ApplicationOfEngland:
_3c)(i) Things and people that are labelled with
ByRef are routed to the Ferry
shigByRef. They are taken to The Isle of CallableProcedures. During their visit they may change themselves if they wish. They must return using the Ferry
ByRef. No further control or action is taken on them by the Port Authorities and they may continue to exist in ApplicationOfEngland in their current form, on their return, be it in their original Form or in any changed Form caused by changes taking place during their visit.
_3c(ii) Things and People labelled with
ByVal have a more interesting experience in their attempt at a visit to The Isle of CallableProcedures. They are stopped at the port Control in ApplicationOfEngland. They are prohibited from visiting The Isle of CallableProcedures. However, they are cloned. Their clone is routed to the Ferry
shigByVal. The clones are allowed all the same experiences as privileges in The Isle of CallableProcedures as their “real” counterparts would have had should they have come to The Port in Application of England with a
ByRef Label. However on Return to the Port Control, ( or shortly after ) in The Isle of CallableProcedures, something unexplained happen. Exactly what happens next is not known. They are routed as may be expected to the Ferry
shigByVal. Theories of what then happens include that on the return trip on the Ferry
shigByVal they are thrown overboard, killed, or in some way they vanish without trace.
_................................
Back to my original “....
you can pass an Array by Value....”
Consider this parallel.
The Port Authorities claim that groups of people, such as a School Class ( Class of School Children Group ) are prohibited from using the Ferry
shigByVal. ( Or in other words, their clones will either not be made or if made not allowed on the Ferry shigByVal . - All amounting in effect to the same thing. )
However A
Variant Bus containing such a group and labelled
ByVal will be permitted to visit The Isle of CallableProcedures in the usually way via The “Clone “ route with Ferry
shigByVal. ( or rather the clone thereof including the Group will be permitted to sail. in Ferry
shigByVal..)
Possible the following explanation, and the parallel in VBA, is the “trick” that allows effectively this contradicting Visit type.
Somehow it is possible for The group to be effected, changed, etc., whilst in the Bus
Variant as if they were free to “roam” in The Isle of CallableProcedures.
To consider my parallel to VBA take a look at my Sub Test4() in post #16 and both Sub test1() and Sub test2() from mikerickson in post # 14. In particular consider the first two code lines in the Procedure called by those Test
Subs(). Somehow I can use the
Variant using things in brackets such as i would do If I had an Actual Array(). And in doing so I change The Array() (
as demonstrated in the examples by changing the number of elements and one Element value ) as it would be changed in the Array() case. But it still is “within” the
Variant. Think of that as being like the Group in the Bus
Variant being able to interact with things in The Isle of CallableProcedures as if they were free to roam normally in The Isle of CallableProcedures. This is possible despite the Bus being closed, or at least closed to the extent that the Port Authorities could not, or did not choose to envisage, that a group of people had sailed / were sailing in the Ferry
shibByVal. (
Of course they were / did. ... i think...)
_....
So A group of School Children ( or rather a clone thereof) visited The Isle of CallableProcedures using the Ferry shigByVal.
An Array() ( or rather Copy thereof ) may be passed to a procedure ByVal
Alan