User Controls for Visual Basic 6.0 Users

Visual Basic 6.0 and Visual Basic 2008 both allow you to create controls; however there are several differences you should be aware of.

Conceptual Differences

In Visual Basic 6.0, UserControl projects (also known as ActiveX Control projects) are used to create ActiveX controls. After they are compiled, UserControl objects can be hosted in any container that supports ActiveX, including Visual Basic 6.0 forms and Internet Explorer.

In Visual Basic 2008, Windows Control Library projects are used to create controls that can be hosted in Windows Forms applications.

Design Time Behavior

In Visual Basic 6.0, before adding a UserControl object to a form at design time, you have to close the UserControl Designer; this step automatically compiles (builds) the control. When subsequent changes are made to the UserControl object, they are not reflected in the instance of UserControl on the form until the application is run; if open, the UserControl Designer automatically closes.

In Visual Basic 2008, a UserControl object can be added to a form without closing the UserControl Designer; however, the user control must be built before it can be added to a form. Simply closing the UserControl Designer does not build the control. Any subsequent changes to the user control are not reflected on the form designer until the UserControl object is rebuilt; a UserControl object is automatically rebuilt each time you debug your test application.

Persisting Values

In Visual Basic 6.0, the ReadProperties and WriteProperties events are used to retrieve or save a UserControl object's values to a PropertyBag object.

In Visual Basic 2008, the PropertyBag object is no longer supported, and the ReadProperties and WriteProperties events no longer exist. Instead, serialization is used to save and retrieve properties in either a binary or SOAP format. For more information, see Walkthrough: Persisting an Object in Visual Basic

Upgrade Notes

When a Visual Basic 6.0 UserControl project is upgraded to Visual Basic 2008, it is upgraded to a Windows Control Library; the resulting control can no longer be hosted in Internet Explorer.

See Also

Tasks

Walkthrough: Persisting an Object in Visual Basic

Concepts

PropertyBag Equivalents for Visual Basic 6.0 Users

Other Resources

Developing Windows Forms Controls at Design Time