Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General / July 2008



Tip: Looking for answers? Try searching our database.

Passing Controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lorin - 29 Jul 2008 02:31 GMT
VB6
I have a picturebox  pic(0) on a form
I want to pass this control to a sub so that I can create an array of pic()
using Load.
How do I pass it as a picturebox?
So far I can only pass it as an Object but would like to get full use of the
picturebox properties etc to appear in the sub.

Private Sub MenuCreate(pic as Object) ' works but cannot see pic properties
etc in sub

Private Sub MenuCreate(pic as PictureBox)  ' errors out Type Mismatch
Private Sub MenuCreate(pic as Control)  ' errors out Type Mismatch
MikeD - 29 Jul 2008 02:51 GMT
> VB6
> I have a picturebox  pic(0) on a form
> I want to pass this control to a sub so that I can create an array of
> pic() using Load.
> How do I pass it as a picturebox?

You can't because that'd be passing a reference to a single control, not the
control array.

> So far I can only pass it as an Object but would like to get full use of
> the picturebox properties etc to appear in the sub.

> Private Sub MenuCreate(pic as Object) ' works but cannot see pic
> properties etc in sub
>
> Private Sub MenuCreate(pic as PictureBox)  ' errors out Type Mismatch
> Private Sub MenuCreate(pic as Control)  ' errors out Type Mismatch

You're just going to have to pass it as an Object. However, you could
declare a local variable of type PictureBox and assign a specific reference
to that in order to get IntelliSense. Personally though, I don't think it'd
be worth it.

Signature

Mike
Microsoft MVP Visual Basic

Lorin - 29 Jul 2008 18:23 GMT
I did try that but could not figure out how to do the assigment to a
picturebox.
Enlighten me with a little sample code.

> > VB6
> > I have a picturebox  pic(0) on a form
[quoted text clipped - 18 lines]
> to that in order to get IntelliSense. Personally though, I don't think it'd
> be worth it.
Jeff Johnson - 29 Jul 2008 21:16 GMT
>> > VB6
>> > I have a picturebox  pic(0) on a form
[quoted text clipped - 22 lines]
>> it'd
>> be worth it.

>I did try that but could not figure out how to do the assigment to a
> picturebox.
> Enlighten me with a little sample code.

Private Sub MenuCreate(pic as Object)
   Dim newPic As PictureBox
   Dim nextIndex As Long

   nextIndex = pic.UBound + 1

   Load pic(nextIndex)

   Set newPic = pic(nextIndex)

   ' Now you can use newPic for the rest of the Sub and get Intellisense
End Sub
Lorin - 29 Jul 2008 22:37 GMT
OK, I see that.  Thanks!

> >> > VB6
> >> > I have a picturebox  pic(0) on a form
[quoted text clipped - 39 lines]
>     ' Now you can use newPic for the rest of the Sub and get Intellisense
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.