Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control Arrays

Status
Not open for further replies.

djcomlab

Programmer
Apr 5, 1999
6
0
0
US
www.toolcity.net
<br>
I need to know how to pass a control array into a sub or function.<br>
I have 5 subs for every control, but the logic is identical.<br>
The only thing that changes is the control reference. For example:<br>
<br>
Private Sub RemoveCol(ByVal rTake As Integer)<br>
Dim intCnt As Integer<br>
Dim intC As Integer<br>
intC = lblCol.count<br>
<br>
Do While lblCol.count &gt; (intC - rTake)<br>
intCnt = lblCol.count<br>
If intCnt = 1 Then Exit Sub<br>
Unload lblCol(intCnt)<br>
Loop<br>
<br>
End Sub<br>
<br>
It would save me a lot of work if I could use a sub like this:<br>
<br>
Private Sub RemoveCTL(ctl as control, ByVal rTake As Integer)<br>
Dim intCnt As Integer<br>
Dim intC As Integer<br>
intC = ctl.count<br>
<br>
Do While ctl.count &gt; (intC - rTake)<br>
intCnt = ctl.count<br>
If intCnt = 1 Then Exit Sub<br>
Unload ctl(intCnt)<br>
Loop<br>
<br>
End Sub<br>
<br>
But it doesn't work. <br>
Is it possible with VB6?<br>
<br>

 
I haven't tested this but try this. Instead of passing as control, pass it as object type.<br>
example: <br>
Private sub RemoveCTL(ctl as Object, ByVal rTake as Integer)
 
Or you could also use,<br>
<br>
Private sub RemoveCTL(ctl as variant, ByVal rTake as Integer) <br>
<br>
Does Work for me!!<br>
<br>
Anand
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top