[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Something like a Pointer

Posted on 2001-06-19
4
Medium Priority
?
162 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 300 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

650 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