Microsoft Forms 20 Object — Library Vb6
You cannot directly drag an MSForms UserForm from the toolbox. Instead, you must instantiate it programmatically:
Dim myForm As MSForms.UserForm Set myForm = New MSForms.UserForm myForm.Caption = "Hello from MSForms" myForm.Width = 300 myForm.Height = 200' Add a control Dim btn As MSForms.CommandButton Set btn = myForm.Controls.Add("MSForms.CommandButton") btn.Caption = "Click Me" btn.Left = 100 btn.Top = 80
myForm.Show
Alternatively, you can create a UserControl or Designer class that hosts MSForms controls at runtime.
| Control | Description | |---------|-------------| | CheckBox | Multiple selection option | | ComboBox | Drop-down list with text entry | | CommandButton | Clickable button | | Frame | Container for other controls | | Image | Picture display | | Label | Static text | | ListBox | Selectable list | | MultiPage | Tabbed interface | | OptionButton | Single selection (radio button) | | ScrollBar | Scrolling control | | SpinButton | Increment/decrement control | | TabStrip | Tab navigation | | TextBox | Text input/output | | ToggleButton | Two-state button |
Or add controls to Toolbox:
Private Function IsFormsLibraryRegistered() As Boolean
On Error GoTo NotRegistered
Dim fm As Object
Set fm = CreateObject("Forms.UserForm.1")
IsFormsLibraryRegistered = True
Exit Function
NotRegistered:
IsFormsLibraryRegistered = False
End Function
' ListBox/ComboBox ListBox1.List = Array("Item1", "Item2", "Item3") ListBox1.ListIndex = 1 ' Select second item ListBox1.MultiSelect = fmMultiSelectMulti' TextBox TextBox1.MaxLength = 50 TextBox1.PasswordChar = "*" TextBox1.MultiLine = True TextBox1.ScrollBars = fmScrollBarsBoth
' CheckBox/OptionButton CheckBox1.Alignment = fmAlignmentLeft CheckBox1.TripleState = True ' Null state allowed
The MultiPage control is a container that hosts multiple pages, each acting as a separate form area. It’s perfect for property sheets and wizards.
' Add a page at runtime MultiPage1.Pages.Add "NewPage", "Page 2", 1' Remove first page MultiPage1.Pages.Remove 0
' Change selected page index MultiPage1.Value = 1 ' Second pagemicrosoft forms 20 object library vb6
Events: Click, Change, BeforeDragOver, BeforeDropOrPaste.