Top Banner
ME 142 Engineering Computation I Custom Dialog Boxes
14

ME 142 Engineering Computation I Custom Dialog Boxes.

Jan 03, 2016

Download

Documents

Raymond Floyd
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ME 142 Engineering Computation I Custom Dialog Boxes.

ME 142Engineering Computation I

Custom Dialog Boxes

Page 2: ME 142 Engineering Computation I Custom Dialog Boxes.

Key Concepts

Custom Dialog Box Overview

Creating a Custom Dialog Box

Example Problems

Page 3: ME 142 Engineering Computation I Custom Dialog Boxes.

Custom Dialog Box Overview

Page 4: ME 142 Engineering Computation I Custom Dialog Boxes.

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.

Page 5: ME 142 Engineering Computation I Custom Dialog Boxes.

Creating a Custom Dialog Box

Page 6: ME 142 Engineering Computation I Custom Dialog Boxes.

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

Page 7: ME 142 Engineering Computation I Custom Dialog Boxes.

Example Problem

Page 8: ME 142 Engineering Computation I Custom Dialog Boxes.

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.

Page 9: ME 142 Engineering Computation I Custom Dialog Boxes.

Example: Dialog Box Design

Page 10: ME 142 Engineering Computation I Custom Dialog Boxes.

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

Page 11: ME 142 Engineering Computation I Custom Dialog Boxes.

Example: Code

Code for the CancelButton: Unload ChangeCase

Page 12: ME 142 Engineering Computation I Custom Dialog Boxes.

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

Page 13: ME 142 Engineering Computation I Custom Dialog Boxes.

Example: Code

Code for the Sub Program:ChangeCase.Show

Page 14: ME 142 Engineering Computation I Custom Dialog Boxes.

Homework Help ‘n Hints