Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » General

Post new topic   Reply to topic
How to Pass Control Array to a Function ?
View previous topic :: View next topic  
Author Message
vb_programmer
Freshman


Joined: 03 Jan 2004
Posts: 31

PostPosted: Jan 17th, 2004 12:35 AM    Post subject: How to Pass Control Array to a Function ? Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger ICQ Number
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Jan 17th, 2004 07:36 AM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Jan 17th, 2004 07:39 AM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
vb_programmer
Freshman


Joined: 03 Jan 2004
Posts: 31

PostPosted: Jan 17th, 2004 07:42 PM    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger ICQ Number
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Jan 18th, 2004 08:33 AM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
vb_programmer
Freshman


Joined: 03 Jan 2004
Posts: 31

PostPosted: Jan 18th, 2004 11:54 AM    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » General All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic