Presentation is loading. Please wait.

Presentation is loading. Please wait.

ME 142 Engineering Computation I Custom Dialog Boxes.

Similar presentations


Presentation on theme: "ME 142 Engineering Computation I Custom Dialog Boxes."— Presentation transcript:

1 ME 142 Engineering Computation I Custom Dialog Boxes

2 Key Concepts Custom Dialog Box Overview Creating a Custom Dialog Box Example Problems

3 Custom Dialog Box Overview

4  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.

5 Creating a Custom Dialog Box

6  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

7 Example Problem

8 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.

9 Example: Dialog Box Design

10 Control/FormPropertyNew Value Change Case UserFormName Caption ChangeCase OK CommandButtonName Caption Default OKButton OK True Cancel CommandButtonName Caption Cancel CancelButton Cancel True Options FrameCaptionOptions Upper Case OptionButton Name Caption Accelerator Value OptionUpper Upper Case U True Lower Case OptionButton Name Caption Accelerator OptionLower Lower Case L Proper Case OptionButton Name Caption Accelerator OptionProper Proper Case P

11 Example: Code  Code for the CancelButton: Unload ChangeCase

12 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

13 Example: Code  Code for the Sub Program: ChangeCase.Show

14 Homework Help ‘n Hints


Download ppt "ME 142 Engineering Computation I Custom Dialog Boxes."

Similar presentations


Ads by Google