Search Tools Links Login

A clean way to add control arrays at runtime!


Visual Basic 6, or VB Classic

This code, will add elements to a control array element at runtime. This is very easy to do, as a control array is actually a collection and gives us a count.

Original Author: Trey Smith

Assumptions

First off, make SURE you do this trick to VB. copy your control on the form, answer YES to create a control array, delete the new instance. Otherwise the control is not a collection.

Side Effects

New control is EXACTLY where the orginal was.

Code

'Load an new instance of myControl
'the index is the count, thus making it one
'greater than the prior index as index is 0 based
'and count starts at 1
Load pbVI(pbVI.Count)
'Count is now 1 greater so to address the control
'you just created reference count -1
With pbVI(pbVI.Count - 1)
'.Left = 100
'.Top = 600
'.Visible = True
End With

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 114 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.