Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using more than 1 instance of a user control on a form

Status
Not open for further replies.

BlackKnight

Programmer
Oct 18, 2000
348
US
Hi,

I have a VB6 user control that has 3 class modules (PublicNotCreateable, notpersistable) in it.

clsDropDown: has a collection in it of clsListItem objects.
clsListItem: simple data holder
clssupercollection: embellishment of VB collection

In the user control when a command button is clicked a form in the user control is displayed with a flexgrid with all of the clsListItem objects in its collection. The collection is always loaded in the form_load event.

When I put the user control (uc1) on a form in another project it works correctly. But when I add another instance of the user control (uc2) to the form it seems that the data displayed in the grid is always that of the 1st control. The data displayed always seems to reflect the first control I place on the form at design time.

Thanx in advance.

Have a good one!
BK
 
Stab in the dark. If your form were called Form1, are you using Form1 as the implicit object reference. The name Form1 is the name of the Form1 class and an implicit (invisible) variable defined as
Public Form1 as New Form1.

If you use Load Form1 or Form1.whatever, then you may be getting the same instance. Try using

' Class Level declarations
Private frm1 as Form1

When the UC is loaded or initialized, use
Set frm1 = New Form1
' Be sure to use
Unload frm1
Set frm1 = Nothing
when closing/terminating the control.

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top