Hey Guys

I try to program a genetic Algo. Generating the Population and mutate/breed them already works fine, as long as i define the class properties as constant Integers. My goal is now to deliver some of these properties by a Userform, and that's where i fail, because the Array i try to deliver is always empty, when the userform finishes.

That's where the 50 classes of the population are initiated

Const PopulationSize As Integer = 50
Public CurrentGen(1 To PopulationSize) As clsLabAssignement
Public NextGen(1 To PopulationSize) As clsLabAssignement
Public MutationRate As Double
Public MaxGenerations As Double
Public SumFitnessScore As Double

Sub EvolveButton_Click()
Set ws1 = Sheets(1)
Set ws2 = Sheets(2)
Set ws3 = Sheets(3)
Set ws4 = Sheets(4)
Set ws5 = Sheets(5)
Set ws6 = Sheets(6)


MaxGenerations = 50
MutationRate = 0.01

For i = 1 To PopulationSize
    Set CurrentGen(i) = New clsLabAssignement
    Set NextGen(i) = New clsLabAssignement
    
    CurrentGen(i).iMutationRate = MutationRate
    CurrentGen(i).iDeviceAmount = ws2.Cells(1, 1)
Next

End Sub

Public iDeviceAmount As Double
Public aDeviceLimits As Variant

Private Sub Class_Initialize()


iDeviceAmount = ws2.Cells(1, 4).End(xlToRight).Column - 3
    
    ReDim aDeviceLimits(1 To iDeviceAmount, 1 To 2)
    If CurrentGen(1) Is Nothing Then
        ModuleTypes.Show
    Else
        aDeviceLimits = CurrentGen(1).aDeviceLimits
    End If
This is the start of the class_initialize, where i try to assign the limits over the Module Types userform, in which the user can put in the different kind of Modules for each of the Devices.
logically the DeviceLimits are the same for every LabAssignement in the same population.

Private Sub OKButton4_Click()
Dim ComboControl As Control
ReDim aDeviceLimits(1 To ws2.Cells(1, 1), 1 To 2)

i = 1
For Each ComboControl In ModuleTypes.Controls
    If TypeName(ComboControl) = "ComboBox" Then
        Module = ComboControl.Text
            
            Select Case Module
            Case "a1", "a2"
                aDeviceLimits(i, 1) = aDeviceLimits(i, 1) + 50
            Case "b1"
                aDeviceLimits(i, 2) = aDeviceLimits(i, 2) + 30
            Case "a3", "a4"
                aDeviceLimits(i, 1) = aDeviceLimits(i, 1) + 30
            End Select
        p = p + 1
    End If
    If p = ws2.Cells(2, i + 3) Then
        i = i + 1
        p = 0
    End If
Next

Unload Me

End Sub
So there are 2 different types of modules (a and b), and for the type a there are again 4 versions. Every different module/version the SpaceLimit in the Device increases.
How is it now possible to deliver this aDeviceLimit array for the First class back to the class_Initialize sub after the Unload Me of the Userform to work with it afterwards? The Calculation in The Userform is correct, but after unloading it, the array is empty again.

I hope you can help me.