0

Example:

Custom Class "myClass"

How to create new variable of "myClass" type:

Dim var1 as myClass

set var1 = new myClass

What I want: After manipulating var1's properties, create var2 as a copy of var1's current state.

What I tried:

(assuming var1 has already been manipulated)

dim var2 as myClass

set var2 = var1

However this ended up in what I think is a set by reference value because whatever I did to var2 after this point, also changed var1. How can I set var2 to be equal to var1 by value?

Community
  • 1
  • 1
  • 1
    [This](https://stackoverflow.com/questions/4805475/assignment-of-objects-in-vb6/4805812#4805812) may answer your question. Not a quick solution though. – jcarroll Sep 12 '17 at 15:36
  • You are discovering the true meaning and functionality of the `Set` keyword. `var1` and `var2` are two pointers to the **same** object reference. If you need two distinct objects, make two distinct objects - you need a way to copy their internal state, VB can't guess that for you. – Mathieu Guindon Sep 12 '17 at 15:39

0 Answers0