| View previous topic :: View next topic |
| Author |
Message |
vb_programmer Freshman
Joined: 03 Jan 2004 Posts: 31
|
Posted: Jan 17th, 2004 12:35 AM Post subject: How to Pass Control Array to a Function ? |
|
|
Hello to all Forum Members ;
First of all , I'm very sorry for asking such a basic question. But I thought that unless I ask it , how will I come to know the solution ?!
I've one control array of Picturebox. Now , look at the function line below ...
Public Function WizardStep(ByVal Container as Picturebox)
Here , when I pass single picture box as an argument to it ; it works fine. But When there is a Control Array of Picture box as PictureBox(0) , PictureBox(1) , PictureBox(2) and so on , then call to the same function gives Type Mismatch Error. I also tried with ByRef rather than ByVal ; but got the same error.
What's the solution to this ? How to pass the Control which has a control array ? _________________ ----- vb_programmer ------
iNova Creations : Software Development Company !
(www.inovacreations.com)
RutuOnline.com : A Programmer's Resource Center !
(www.rutuonline.filetap.com) |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Jan 17th, 2004 07:36 AM Post subject: |
|
|
So let me get this straight... You want to pass the name of the controls and access them all, not just one picture box like this :
| Code: | | WizardStep Picture1(0) |
Is that right? _________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Jan 17th, 2004 07:39 AM Post subject: |
|
|
Something like this? With some error handling of course :
| Code: | Private Sub Form_Load()
WizardStep Form1, "Picture1", True
End Sub
Public Function WizardStep(Parent As Form, Container As String, Optional ControlArray As Boolean = False)
If ControlArray = True Then
MsgBox Parent.Controls(Container)(0).Name
Else
MsgBox Parent.Controls(Container).Name
End If
End Function |
_________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
vb_programmer Freshman
Joined: 03 Jan 2004 Posts: 31
|
Posted: Jan 17th, 2004 07:42 PM Post subject: |
|
|
Yes ... you've got me correct ... I'm looking for something of that sort only. Actually , I can't pass just the control array as it is to the function ... hence Function (Container() as PictureBox) is not working. _________________ ----- vb_programmer ------
iNova Creations : Software Development Company !
(www.inovacreations.com)
RutuOnline.com : A Programmer's Resource Center !
(www.rutuonline.filetap.com) |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Jan 18th, 2004 08:33 AM Post subject: |
|
|
Does my sample work for you? _________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
vb_programmer Freshman
Joined: 03 Jan 2004 Posts: 31
|
Posted: Jan 18th, 2004 11:54 AM Post subject: |
|
|
Thanks for your reply ... Actually , upon thinking on this problem , this what I have came to ....
(Please see the attached File as a Demo of what solution I have developed ) _________________ ----- vb_programmer ------
iNova Creations : Software Development Company !
(www.inovacreations.com)
RutuOnline.com : A Programmer's Resource Center !
(www.rutuonline.filetap.com) |
|
| Back to top |
|
|