[AccessD] ParamArray problem

John W. Colby jwcolby at colbyconsulting.com
Thu Mar 11 06:17:17 CST 2004


>Haven't looked into the Paramarray question as I've always passed arrays of
strong types or of variants.

In this case the array will be passing in objects, i.e. classes, but the
class instances can be a combo class, a text class, a list class etc.  Since
each is a different class, I pass them as objects.  Indeed you dim the array
as specific class types AFAICT.

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Jürgen Welz
Sent: Thursday, March 11, 2004 1:05 AM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] ParamArray problem


In .NET, if you pass an object ByVal, it is still passed ByRef.  No error or
notification.  It just changes it.  Haven't looked into the Paramarray
question as I've always passed arrays of strong types or of variants.



Ciao
Jürgen Welz
Edmonton, Alberta
jwelz at hotmail.com





>From: bruce_bruen at mlc.com.au
>
>
>
>
>
> >"for each next" to iterate the array and found something
>in an "empty" array."
>
>Now that does sound strange.
>
>The VB help for .NET certainly says that FOREACH should not execute on a
>paramarray with .length=0
>However, prior to .NET all paramarrays were passed as byrefs (hence my
>comment on them being heap pointers)  in .NET they are always byvals.
>
>Looks like there may be a situation in the VBA where the pointer is
>initialised to a "random" heap pointer
>under some circumstances - that would be bloody great hole!
>
>have fun
>B
>
>
>
>                       "John W. Colby"
>
>
>
>
>
> >I also seem to remember that passing objects in paramarrays is a nono you
>can only pass value items (???)
>
>Help says objects can be passed, or at least the array can be declared as
>type object.
>
>And I was using a "for each next" to iterate the array and found something
>in an "empty" array.
>
>John W. Colby
>www.ColbyConsulting.com
>
>-----Original Message-----
>From: accessd-bounces at databaseadvisors.com
>[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of
>bruce_bruen at mlc.com.au
>Sent: Wednesday, March 10, 2004 11:58 PM
>To: Access Developers discussion and problem solving
>Subject: Re: [AccessD] ParamArray problem
>
>
>
>
>
>
>John,
>
>What you've written it looks right, bu I must ask how do you know there is
>"something" in the ParamArray?  I would not expect it to be equal to a
>null, it is (I can remember which) actually a stack or heap pointer.  I
>also seem to remember that passing objects in paramarrays is a nono you can
>only pass value items (???) , but its been months since I've VBA'd so to
>speak so I could be wrong on that.
>
>
>...meanwhile back to the C#
>
>hth
>Bruce
>
>
>
>                       "John W. Colby"
>                       <jwcolby at colbyconsulting.        To:       "AccessD"
><AccessD at databaseadvisors.com>
>                       com>                             cc:
>                       Sent by:                         Subject:  [AccessD]
>ParamArray problem
>                       accessd-bounces at databasea
>                       dvisors.com
>
>
>                       11/03/2004 15:43
>                       Please respond to Access
>                       Developers discussion and
>                       problem solving
>
>
>
>
>
>
>I am doing an init() method of a class that looks like:
>
>Public Sub Init(ByRef robjParent As Object, ParamArray lDepObjsArr() As
>Variant)
>
>where robjParent = a pointer to the parent class (ME)
>
>and ParamArray lDepObjsArr() As Variant MAY BE an array of dependent object
>classes but specifically at the moment isn't being passed anything.  I.e.
>the calling function looks like
>
>MyClass.Init me
>
>I am passing in a pointer to self in the first parameter and nothing at all
>for the array.
>
>Since it is an array that can contain variable number of objects I expected
>it to allow this.  However when I get inside the init() the lDepObjsArr has
>something in it.  That something is NOT a class, and I can't debug.print
>the
>value...
>
>What the heck is going on here?  Can I not do this (not pass anything to a
>paramarray?
>
>John W. Colby
>www.ColbyConsulting.com

_________________________________________________________________
STOP MORE SPAM with the MSN Premium and get 2 months FREE*
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=htt
p://hotmail.com/enca&HL=Market_MSNIS_Taglines

--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com






More information about the AccessD mailing list