CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Dec 2012

    Set a new Class module using a pointer to another one


    My purpose is to reach a result like this:
    Dim clsA As New Class1
    Dim clsB As New Class1
    Set clsB = clsA
    but using pointers to object and the CopyMemory API call.

    The reasons why I've to pass trough this way are several and hard to explain.

    I tried this code:
    Dim ptrA As Long, ptrB As Long
    ptrA = ObjPtr(clsA)
    ptrB = ObjPtr(clsB)
    CopyMemory ptrB, ptrA, 4
    but nothing happens, because (although clsA is initialized) clsB always seems to be empty (any property value of clsA is set to clsB).

    I also tried to call the ObjPtr() function inside the Class1 module like this:
    ptr = ObjPtr(Me)
    but neither this time I gave results.

    Can you help me?

  2. #2
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: Set a new Class module using a pointer to another one

    You need to place the first set of calls into a normal MODULE, and set the references to PUBLIC. Then, they will be shared throughout the application.

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.