
How to pass control arrays to subs
Matt, do you mean something like this ??
Dim myWinsockAry As Collection
Private Sub Form_Load()
Dim i As Integer
Set myWinsockAry = New Collection
i = 1
For i = 1 To 3
Load myWinSock(i)
myWinSock(i).LocalPort = i
myWinsockAry.Add myWinSock(i)
Next i
Call spudBoy(myWinsockAry)
End Sub
Private Sub spudBoy(sockAry As Collection)
Dim i As Integer
i = 1
For Each Control In sockAry
Debug.Print "WinSock Control Port : " & sockAry.Item(i).LocalPort
i = i + 1
Next
End Sub
Quote:
> Ok, so I've got this winsock control array. Now, we all know that we can
> load additional instance of the control by doing something like:
> Load Winsock1(1)
> Load Winsock1(2)
> Okay, now, I want one of my classes to do this for me. So here's the
> question: how do I pass the control array to the class? I can't do this...
> Public Sub MySubInAClass(Winsock1 As Winsock)
> Load Winsock1(1)
> Load Winsock1(2)
> End Sub
> The compiler will say, hey stupid, you only got one winsock control, you
> can't load more of 'em.
> What I do now (which I really hate) is pass the sub the entire form and
> access the winsock control from the form like this:
> Public Sub MySubInAClass(fMain As frmMain)
> Load fMain.Winsock1(1)
> Load fMain.Winsock1(2)
> End Sub
> So anyone have any ideas?
> Thanks,
> Matt