Solved

Something like a Pointer

Posted on 2001-06-19
4
157 Views
Last Modified: 2010-05-02
Hello,

I need something like a pointer to tell a class module where to get its data from. Is there such a possibility in Visual Basic?

Gretting
zz

0
Comment
Question by:zzconsumer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 6205550
ByRef

in your class module you make a function like

public function myFunction(ByRef myData as string)
   msgbox myData
   myData = "Newstring"
end function

now you just pass the reference like

Dim str as string
str = "test"
call objectreference.myFunction(str)
msgbox str

Regards,
CJ
0
 
LVL 28

Accepted Solution

by:
Ark earned 100 total points
ID: 6205639
Hi

At ClassModule_Initialize event:

  MyClassPointer = ObjPtr(Me)

At bas module:

Public MyClassPointer As Long

Public Function ResolvePointer(ByVal lpObj&) As MyClass
  Dim oMC As MyClass
  CopyMemory oMC, lpObj, 4&
  Set ResolvePointer = oMC
  CopyMemory oMC, 0&, 4&
End Function

Now any time you want access any of your class properties or methods, just call:

Call ResolvePointer(MyClassPointer).MyMethod(params)
Or ResolvePointer(MyClassPointer).MyProperty = NewProperty

Cheers
0
 
LVL 1

Author Comment

by:zzconsumer
ID: 6205682
Can i also tell the class which Property of a known class to allocate? The thing is that I made a class that returns arrays using different Properties as Variant.
0
 
LVL 1

Author Comment

by:zzconsumer
ID: 6230438
Well, I had not time to check it out, but Ark's solution looks like it comes closest to what I need.

Thanks.
zz
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question