nickninevah
New Member
- Joined
- Dec 21, 2018
- Messages
- 6
Hello everyone. I have some custom defined VBA classes and no idea why they keep causing Excel to crash. My classes define objects. I use instances of those objects in dynamic arrays. I can't use collections because I need to edit the objects in the arrays and swap out the entries in the arrays. As part of the class definition, I have a method to clone the object. It duplicates all internal variables into a new object, completely independent. This method works perfectly fine, except when my source object and target object are entries in an array.
Here is the skeleton version of my code:
Class definition:
CHROMOSOME
Example of usage:
And I have error handling code included. But every time, excel just crashes. No warning. no error message, nothing. All my functions and subroutines use ByRef arguments for passing my arrays. Any ideas?
Here is the skeleton version of my code:
Class definition:
CHROMOSOME
Code:
Public Sub Clone(ByRef cloneIn As Chromosome)
'Create new object
Set cloneIn = New Chromosome
'Copy over the variables
....
End Sub
Example of usage:
Code:
Dim popOut() As Chromosome
Dim pChromo() as as Chromosome
Dim i As Long 'Counting variable
Dim j As Long 'counting variable
Redim popOut(1 to j)
Redim popOut(1 to j)
for i = 1 to j
pChromo(i).Clone popOut(i)
next
And I have error handling code included. But every time, excel just crashes. No warning. no error message, nothing. All my functions and subroutines use ByRef arguments for passing my arrays. Any ideas?