In previous versions of Visual Basic, binding a data source (such as the Data control) to a data consumer (such as the DBCombo control or simply to a text box) could only be done at design-time. Visual Basic now allows you to bind almost any data source to any data consumer at run time. For example, at run time, you can now set the DataSource property as shown below:
Text1.DataMember = "Employees"
Text1.DataField = "Salary"
Set Text1.DataSource = DataEnvironment1
With this capability, you can also bind controls that have been added to the Controls collection using the new Add method. The code below adds a user control and binds it.
Private myCtl As Extender
Form1.Licenses.Add "Project1.userControl1", "uc1_Key"
Set myCtl = Form1.Controls.Add("Project1.userControl1", "Ctl_Key")
myCtl.DataMember = "Employees"
myCtl.DataField = "Salary"
Set myCtl.DataSource = DataEnvironment1
The only data sources that cannot be bound in this manner are the intrinsic Data control and the RemoteData Control.
In addition to this flexibility, you can also create your own data source using new data-aware features of the class module. Once you have created such a data source, you can also bind it at run time to a data consumer using the BindingCollection object. For details, see Creating Data-Aware Classes and Creating a Data Source.
Visual Basic 6.0 also allows you to create your own user controls that function as data sources.
For More Information For more information about new data-bound controls, see Forms and Data-Aware Controls.