1 / 15

Dialog Boxes – Day 1

Dialog Boxes – Day 1. Built-in Dialog Boxes Input Box Message Box Custom Dialog Boxes – User Forms. Form. Title: form property. Label. Text Box. Command Buttons. Form Controls. Built-in boxes Form: overall rectangle Controls: tools used to make box function. User Form Design.

arden
Download Presentation

Dialog Boxes – Day 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  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. Text Box Check Box, Toggle Frame, Option Buttons Combo Box, List Box Data Collection • Data types • Text • Numbers • Yes/No • Exclusive options • Lists • Choose control to fit

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

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

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

  8. Insert User Form Form name Form properties

  9. Form Tools • Label • Text Box • Command button

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

  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

More Related