me 142 engineering computation i custom dialog boxes
TRANSCRIPT
ME 142Engineering Computation I
Custom Dialog Boxes
Key Concepts
Custom Dialog Box Overview
Creating a Custom Dialog Box
Example Problems
Custom Dialog Box Overview
Custom Dialog Box Overview
A custom designed window or dialog box More powerful and flexible than InputBox Creates a professional looking window style
interface My include controls such as buttons, list
boxes, text boxes, radio buttons, scroll bars, etc.
Creating a Custom Dialog Box
Creating a Custom Dialog Box
Determine basic design and use Activate VBE and insert a UserForm Add controls to the UserForm Modify Properties for the controls as needed Write code that is executed when controls are
activated Write code that displays the UserForm
Example Problem
Example: Change Case
Create a macro which utilizes a custom dialog box to perform changes of text in selected cells to uppercase, lowercase, or proper case.
Example: Dialog Box Design
Example: Dialog Box DesignControl/Form Property New Value
Change Case UserForm NameCaption
ChangeCaseChange Case
OK CommandButton NameCaptionDefault
OKButtonOKTrue
Cancel CommandButton NameCaptionCancel
CancelButtonCancelTrue
Options Frame Caption OptionsUpper Case OptionButton
NameCaptionAcceleratorValue
OptionUpperUpper CaseUTrue
Lower Case OptionButton
NameCaptionAccelerator
OptionLowerLower CaseL
Proper Case OptionButton
NameCaptionAccelerator
OptionProperProper CaseP
Example: Code
Code for the CancelButton: Unload ChangeCase
Example: Code
Code for the OKButton:If OptionUpper Then
For Each cell In Selection cell.Value = UCase(cell.Value) Next cell ElseIf OptionLower Then For Each cell In Selection cell.Value = LCase(cell.Value) Next cell ElseIf OptionProper Then For Each cell In Selection cell.Value =
WorksheetFunction.Proper(cell.Value) Next cell End If Unload ChangeCase
Example: Code
Code for the Sub Program:ChangeCase.Show
Homework Help ‘n Hints