Re: if I can get a pointer with objptr



Using a golbal variable seems to work quite well so I'll go with it.
It has also allowed a solution to an other problem. Also is there a way
to know if a form has been open as a dialog with DoCmd.openForm
"frmName, acNormal,,,,acDialog?

Bob Hairgrove wrote:
On 16 Dec 2006 10:39:46 -0800, "asc4john" <john@xxxxxxxxxx> wrote:

I want to pass that "pointer" to another form. Using openargs and
passing a string, then using Me.Tag to pass back a string has become
very clumsy. Since OpenArgs is actually a variant there must be a
better way. Altough I can set one global collection and pass thru that
I would rather just pass a pointer around.

I think it was Bill Gates himself who decided that VB and VBA would
not support pointers ... the "ObjPtr" thing was a kludge invented to
provide a work-around for the limitations (at the time) of the COM
object model.

Every variant has a subtype ... internally, a variant in VBA is
implemented as a C union. I can't point you to a reference for this,
but I believe it is adequately documented somewhere (others: please
feel free to pitch in with links!) Therefore, it is not possible to
simply assign one variant to another without some intermedient
"compiler magic" (or interpreter magic, in the case of VBA).

Have you considered custom database properties? Check out the help
file topic for the Properties collection and the Property attribute.

If we grant that you could somehow do what you propose (i.e. using
pointers), and you would be doing it as indicated by your short
example code, then you would need to consider the lifetime of the
object you are passing around. It looks to me like you NEED to have a
global object (because after you leave the procedure where you have
defined the Collection object, its lifetime would be undefined).

Bob Hairgrove wrote:
On 15 Dec 2006 18:52:33 -0800, "asc4john" <john@xxxxxxxxxx> wrote:

If I can get a pointer with objptr. Why can't I go the other way.

dim cll as Collection
dimcll2 as Collection
dim ptr as long

ptr = ObjPtr(cll) '
but set cll2 = ptr ERROR

I am not asking to do this
Set SomeWierdNonCollectionThingy = ptr

Why not just:

set cl2 = cl1

???

--
Bob Hairgrove
NoSpamPlease@xxxxxxxx

--
Bob Hairgrove
NoSpamPlease@xxxxxxxx

.



Relevant Pages

  • Re: How to make (ptr + len) > lim safe?
    ... Meaning I use ptr < lim where ptr and lim are both pointers ... However, if ptr and lim both point into or one past the end of the same array, and if ptr < lim, then lim-ptr has to be positive, and that is something the standard does say. ... Not directly, but by inference from what it says about the binary '-' operator and the '<' operator, when acting on pointers: ...
    (comp.lang.c)
  • Re: C++ Conversion functions for pointers
    ... > and later you accessed that array through itsArray. ... > If you start to use an array of pointers, then the UB I referred to is no ... >> Variant(or Derived from Variant) before allocating. ... The operator newthat you can overload ...
    (alt.comp.lang.learn.c-cpp)
  • Re: C++ Conversion functions for pointers
    ... I know I can create an array of Variant pointers and assign to these ... >> But the problem I am having is converting an int pointer to a Variant ...
    (alt.comp.lang.learn.c-cpp)
  • Re: regarding * and ++ operators
    ... The first area of confusion. ... declares ptr as a pointer to data of type char. ... It is comparatively rare for pointers to point to sinle objects. ...
    (comp.lang.c)
  • Class properties or function?
    ... I've got a COM add in for Word and I'd like to use VBA macros to process ... Public Property Let myTag(ByVal strReturnValue As Variant) ... Dim frmForm As Form ...
    (microsoft.public.vb.general.discussion)