Dim officeBox As MSForms.TextBox Set officeBox = UserForm1.TextBox1 Use code with caution. Event Differences
: The Microsoft Forms 2.0 library is not a redistributable part of VB6 runtime. Solution :
This code snippet demonstrates how to leverage the Controls collection to interact with all MSForms controls on a form. Similar techniques can be used for other controls. microsoft forms 20 object library vb6
Although VB6 has its own intrinsic controls (e.g., VB.CommandButton ), the Microsoft Forms 2.0 controls offer specific advantages:
Private Sub Form_Load() With ComboBox1 .ColumnCount = 2 ' Set the control to display 2 columns .BoundColumn = 1 ' The value returned comes from column 1 .TextColumn = 2 ' The text displayed in the box comes from column 2 ' Add rows of data .AddItem "EMP001" .List(0, 1) = "John Doe" .AddItem "EMP002" .List(1, 1) = "Jane Smith" End With End Sub Use code with caution. Example 2: Handling the Forms 2.0 TextBox Change Event Dim officeBox As MSForms
Because they are Office components, you may encounter licensing errors when trying to create these controls on a machine that does not have Microsoft Office or Visual Studio installed. 3. Behavioural Differences
Because the Forms 2.0 controls belong to a different object model, interacting with them in code requires specific syntax. Below are practical examples demonstrating how to manipulate these controls dynamically. Similar techniques can be used for other controls
However, due to strict redistribution licensing limits, it is best utilized for where standard operating environments guarantee that Microsoft Office is universally installed on all client workstations. For commercial, public software distribution, developers should opt for native VB6 control wrappers, custom user controls (CTLs), or modern third-party Unicode-compliant ActiveX suites.
Private Sub SpinButton1_SpinDown() If IsNumeric(TextBox1.Text) Then TextBox1.Text = Val(TextBox1.Text) - 1 End If End Sub