this is my code
Function GenerateInterface()
Dim ObjectsArray() As VB.Control
Dim TmpCtrl As VB.Control
ReDim ObjectsArray(1)
For Each TmpCtrl In Me.Controls
If TmpCtrl.Container Is frConfigVars(0) Then
Set ObjectsArray(UBound(ObjectsArray) - 1) = TmpCtrl
ReDim Preserve ObjectsArray(UBound(ObjectsArray) + 1)
End If
Next TmpCtrl
For i = 1 To UBound(Variables) - 1 'global array containing how many frames I need
Load frConfigVars(i)
frConfigVars(i).Left = 0
frConfigVars(i).top = frConfigVars(i - 1).top + frConfigVars(i - 1).Height
frConfigVars(i).Visible = True
For x = 0 To UBound(ObjectsArray) - 1
Set TmpCtrl = ObjectsArray(x)
Load TmpCtrl(i) '<-- crashes here
'stuff to move and view new object
Next x
Next i
End Function
It basically loads into a controls array the 0-indexed objects present in the frame to make me dinamycally load them how many times I need but I can't manage to load a new control from a variable itself.
I kinda got why that loading is crashing, I'm guessing the TmpCtrl contains (example) txtbox(0) and not txtbox, which I'd need to load the new object, correct? If so, how can I load the new control?
I can't create objects from scratch because there are many of them and positioning would be hell I can't call them by their name because with time I will add/remove some stuff so I don't want to touch this function again once it works
Thanks