|
-
Sep 10th, 2008, 04:46 AM
#1
Thread Starter
Fanatic Member
help Array with events
Hi, I need to declare an array which will be used to add controls to a form such as this
vb Code:
Public picBatch() As Control
Public intControlIndex As Integer
intControlIndex = UBound(picBatch) + 1
ReDim Preserve picBatch(intControlIndex)
Set picBatch(intControlIndex) = Controls.Add("VB.PictureBox", "PicBatch_" & CStr(intControlIndex))
I need to then assign my own tags.
IE. picBatch(1).AtStart = true
how do I do this?
-
Sep 10th, 2008, 01:03 PM
#2
Re: help Array with events
Its not an easy solution but it is possible.
See penagates FAQ and code examples on the topic.
http://www.vbforums.com/showthread.php?t=372811
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 10th, 2008, 01:37 PM
#3
Thread Starter
Fanatic Member
Re: help Array with events
 Originally Posted by RobDog888
can this be done with an array declared as a picturebox?
perhaps i can just make a new variable that links with the array variable and use events?
sorry I have no knowledge of making variables with events.
-
Sep 10th, 2008, 03:39 PM
#4
Re: help Array with events
I would think so but I didnt write it so I may not be the best to answer you. Perhaps send PG a pm with a link to this thread.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 11th, 2008, 01:53 AM
#5
Re: help Array with events
 Originally Posted by TheUsed
can this be done with an array declared as a picturebox?
Yes: you need to use the second solution (after the divider in that post).
Make an interface class which defines method stubs for every picturebox event which you need to handle. Ensure that each method has an argument which is the reference to a picturebox.
Make a class which contains: (1) a callback property declared using the interface type, which will reference your form, and (2) a reference to a picturebox object declared using WithEvents. In this class, handle each event which you declared in the interface, and in each event handler, call the corresponding method using the callback property you created in (1).
Implement that interface in your form; you can use the picturebox argument of each method to determine where the event was fired from. (Make sure you pass this argument from the event wrapper class!) In the Form_Load event, you can create the array of references to wrapper classes. Set the callback property to 'Me'. This is shown in the FAQ post.
I'd write an example of this exact technique for you, but it's been so long since I used VB6 that I'd get the syntax wrong and mislead you. Hopefully, if you need, someone else can take what I described and create code to do it.
-
Sep 17th, 2008, 10:34 PM
#6
Thread Starter
Fanatic Member
Re: help Array with events
im affraid this is more than I know when it comes to VB6, any way I can get some code examples?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|