With refactoring some old VB6 code I stumbled upon some really weird behavior. When I try to set the DragMode property of an element of a control array, the compiler tells me 'Method or data member not found' when I separate this control from its array.
See my example below where 'myControl' is nothing else but a User Control with a Textbox in it. And where 'Controls' is a Control Array with myControls in it. The first loop works and the second one doesn't.
Dim i As Integer
Dim ctrl As myControl
For i = 0 To 2
myControls(i).DragMode = vbAutomatic
Next i
For Each ctrl In myControls
ctrl.DragMode = vbAutomatic
Next
Update:
With thanks to @wqw I got the for each loop working. The code that works for me now looks something like this:
Dim ctrlExt As VBControlExtender
Dim ctrl As myControl
For Each ctrlExt In myControls
Set ctrl = ctrlExt
ctrlExt.DragMode = vbAutomatic
ctrl.SpecificProperty = "Test"
Next