How to pass control arrays to subs 
Author Message
 How to pass control arrays to subs

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



Mon, 21 Jul 2003 00:39:37 GMT  
 How to pass control arrays to subs
Hi Matt:

Quote:
> how do I pass the control array to the class?  I can't do this...

> Public Sub MySubInAClass(Winsock1 As Winsock)

Pass it as Object instead of WinSock

Doug.



Mon, 21 Jul 2003 03:29:16 GMT  
 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

  tdm3.vcf
< 1K Download


Mon, 21 Jul 2003 05:47:36 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help how to pass control arrays to sub ??

2. Passing Control Arrays to Sub-Procedures

3. Passing control arrays to subs

4. Q: Passing first (original) element of a control array to a SUB

5. Passing an Array of Controls to a Sub

6. Pass control array to sub/function ?

7. Passing Control Array to a SUB/FUNCTION

8. pass an array as function/sub argument

9. Question on passing array parameters to VB.NET Sub/Function

10. Problem in passing datarow array from one sub to other

11. Passing Arrays from Sub to Program

12. Help! Problem passing string array to sub

 

 
Powered by phpBB® Forum Software