Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dialog Boxes – Day 1 Built-in Dialog Boxes Input Box Message Box Custom Dialog Boxes – User Forms.

Similar presentations


Presentation on theme: "Dialog Boxes – Day 1 Built-in Dialog Boxes Input Box Message Box Custom Dialog Boxes – User Forms."— Presentation transcript:

1 Dialog Boxes – Day 1 Built-in Dialog Boxes Input Box Message Box Custom Dialog Boxes – User Forms

2 Form Controls Built-in boxes Form: overall rectangle Controls: tools used to make box function Form Title: form property Label Text Box Command Buttons

3 User Form Design Decide what data to collect Design form layout Select form tools Write code to use data What event triggers? How is data used? Write macro to display form

4 Data Collection Data types Text Numbers Yes/No Exclusive options Lists Text Box Check Box, Toggle Frame, Option Buttons Combo Box, List Box Choose control to fit

5 Example: Temperature Convert °F to °C Decide on Inputs Name Temp, °F Determine Output Name + °C Determine action Event – button? Psuedocode Display Name, Temp in °C Start Get Name, Temp in °F Convert °F to °C End

6 Example: Temperature Pseudocode Ask for user’s name Ask for temp, °F DegC = (DegF-32)*5/9 Display name and DegC Display Name, Temp in °C Start Get Name, Temp in °F Convert °F to °C End

7 Temperature Form Layout Name Temp, °F Output Area Go Input Label Output Action x  Use form to collect inputs, display output

8 Insert User Form Form name Form properties

9 Form Tools Label Text Box Command button

10 Object Names Text Boxes txtName txtDegF Labels lblOut Buttons cmdOK Object and variable names must be different! User Form Objects

11 Action Code Event Driven Form events tied to object on form Double-click object to add code VBA selects name based on form object Form holds data, does nothing Code tells VBA how to use it Data called by object name Assignment statements tell use

12 Action Code

13 Form Process Ron 86 Ron, the temperature is 30 Degrees C

14 Display Macro Form won’t appear until its called Need a macro Goes in module, not form code Need name of form Only one line of code Sub ShowForm( ) MyForm.Show End Sub

15 Hiding Forms You choose when After code runs Separate button Two forms MyForm.hide – form still active Unload MyForm – closes form Unload Me


Download ppt "Dialog Boxes – Day 1 Built-in Dialog Boxes Input Box Message Box Custom Dialog Boxes – User Forms."

Similar presentations


Ads by Google