Visual Basic for Applications/Custom Dialog Boxes

From Wikiversity
Jump to navigation Jump to search

This lesson introduces custom dialog boxes.

Objectives and Skills[edit]

Readings[edit]

Multimedia[edit]

Examples[edit]

'This macro displays and processes a custom UserForm.

Option Explicit

Private Sub UserForm_Initialize()
    Me.ComboBox.AddItem "One"
    Me.ComboBox.AddItem "Two"
    Me.ComboBox.AddItem "Three"
End Sub

Private Sub OK_CommandButton_Click()
    MsgBox "You selected " & Me.ComboBox.Value, vbOKOnly + vbInformation, "Custom Dialog Box"
    Unload Me
End Sub

Private Sub Cancel_CommandButton_Click()
    Unload Me
End Sub

Activities[edit]

See Also[edit]

References[edit]

Nuvola apps edu miscellaneous.svg Type classification: this is a lesson resource.