Lab 9 – User Forms Design. User Forms What are user forms? –Known as dialog boxes –Major ways for getting user input An example of using user forms: Monthly.

Slides:



Advertisements
Similar presentations
Prof. Yitzchak Rosenthal
Advertisements

Microsoft Office XP Microsoft Excel
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Using Macros and Visual Basic for Applications (VBA) with Excel
Developing an Excel Application
EXCEL Spreadsheet Basics
Customizing Reports. Custom Reports A report is a formatted hardcopy of the contents of one or more tables from a database. Although you can format and.
1.
Excel and VBA Creating an Excel Application
Chapter 12: Recording Macros Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
FIRST COURSE Excel Lecture. XP 2 Introducing Excel Microsoft Office Excel 2007 (or Excel) is a computer program used to enter, analyze, and present quantitative.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Controls General Discussion. VB Controls Visual Basic Controls A control is the generic name for any object placed on a form Controls may be images,
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
WORKING WITH MACROS CHAPTER 10 WORKING WITH MACROS.
Laboratory Exercise # 13 – Font and Number Format Styles Office Productivity Tools 1 Laboratory Exercise # 13 Font and Number Format Styles Objectives:
Lesson 1 – Microsoft Excel The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
XP New Perspectives on Microsoft Access 2002 Tutorial 51 Microsoft Access 2002 Tutorial 5 – Enhancing a Table’s Design, and Creating Advanced Queries and.
XP Week 6 – ABC By Aurino Djamaris Bakrie School of Management.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
IN THE NAME OF ALLAH UserForms on VBA Lab 06 Tahani Al_dweesh.
Ch 11: Userforms CP212 Winter Topics Designing User Forms o Controls Setting Properties o Tab Order o Testing Writing Event Handlers o Userform_Initialize.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
Creating a Web Site to Gather Data and Conduct Research.
Adding User Interactivity – Lesson 51 Adding User Interactivity Lesson 5.
Chapter 2 More Controls Programming in C#. NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
Chapter 3: Using GUI Objects and the Visual Studio IDE.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 2 Creating a User Interface.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Chapter 12: Recording Macros Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
Tutorial 11 Five windows included in the Visual Basic Startup Screen Main Form Toolbox Project Explorer (Project) Properties.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 15 Advanced Tables.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Access Project 7 Advanced Report and Form Techniques.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays.
INSERT BOOK COVER 1Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Getting Started with VBA for Microsoft Office 2010 by.
Fall 2003Sylnovie Merchant, Ph.D. ACCESS Tutorial Note: The purpose of this tutorial is to provide an introduction to some of the functions of ACCESS in.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
1 Visual Basic Part I - A tool for customizing your program Principles of GIS
The Excel model for information processing The Excel model is a grid of cells in which items of information are stored and processed. Any information that.
Lab 10. User Forms Design – Code Part ► Lab 9 Review ► Continue ‘Student Record’ Example ► A Car Loan Application.
Nolan Tomboulian Tomboulian.Wikispaces.com 1.
Chapter 2 More Controls Programming in C#. NET Objectives Use text boxes, group boxes, check boxes, radio buttons, and picture boxes effectively.
Extracting Information from an Excel List The purpose of creating a database, or list in Excel, is to be able to manipulate the data elements in ways that.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Prepared by the Academic Faculty Members of IT. Tables Creating Tables. Merging Cells. Splitting Cells. Sorting Tables. Performing Calculations.
1 CA202 Spreadsheet Application Automating Repetitive Tasks with Macros Lecture # 12 Dammam Community College.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Introducing UserForms Joanna Wyrobek 1. Ms Excel UserForms A UserForm object is a window or dialog box that makes up part of an application's user interface.
Working with UserForms Dr Joanna Wyrobek 1. Displaying a modeless UserForm By default, UserForms are displayed modally. This means that the UserForm must.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Excel Tutorial 8 Developing an Excel Application
Chapter 1: An Introduction to Visual Basic 2015
Developing an Excel Application
How to design a Windows Forms application
User Forms.
Microsoft Excel 2003 Illustrated Complete
Chapter 7 Advanced Form Techniques
Variables and Arithmetic Operations
UserForm.
Custom dialog boxes Unit objectives
Using Templates and Library Items
Presentation transcript:

Lab 9 – User Forms Design

User Forms What are user forms? –Known as dialog boxes –Major ways for getting user input An example of using user forms: Monthly Sales Application (Chapter 12, p. 188) A company has stores in three regions with each region selling different set of products. This application mainly focuses on summarizing the sales for a particular product in a particular region (based on the user’s choices).

Example: Monthly Sales Application An explanation sheet summarizes what an application is about and how it works. It is good for every application to have such kind of explanation sheet at the beginning to tell users what it is about The button on this sheet is attached to a macro that runs the application.

How to Create Your Own User Forms Design the user form to have desired functionality and look attractive (first part) Make the designed user form functional: write event handler code or event code (VBA code) to respond to users’ actions (second part) For example, in the previous Monthly Sales application, if a user clicks on the OK button (this is an event), certain actions should occur – the users’ inputs should be captured in some way, the dialog box (or the user form) should disappear, etc. Such actions should be fulfilled through code (event code).

Designing User Forms Major things you need to know: –What are controls – Objects with certain properties and methods –Which controls (also called ActiveX controls) are available –How to place, resize, and line up controls on a user form –How to specify or change controls’ properties in the Properties window (in VBE)

To Start … First, open a new workbook in EXCEL, get into the VBE, and make sure you can see Project Explorer and Property windows (Go to View menu item to open them) Select the current project, then use Insert\ UserForm to create a blank user form.

Available Controls The available controls are those shown in the Toolbox. The arrow at the top left is used only for pointing Each of the rest, starting with the letter “A”, has a name (from the left to right, top to bottom): First row: Label, Textbox, ComboBox, ListBox Second row: CheckBox, OptionButton, ToggleButton, Frame, CommandButton Third row: TabStrip, MultiPage, ScrollBar, SpinButton, Image Fourth row: RefEdit (highlight a worksheet range)

Introduction to Major Controls CommandButton – used to run subs (the user clicks on a button and a sub runs) Label – used mainly for explanation and prompts TextBox – used to obtain any type of user input (the user types something in the box) ListBox – used to let the user choose one or more items from a list ComboBox – similar to a list box, except that the user can type an item that isn’t on the list in a box CheckBox – used to let the user check whether an option is desired or not (any or all of a set of check boxes can be checked) OptionButton – used to let the user check which of several options is desired (only one of a set of option buttons can be checked) Frame – usually used to group a related set of options buttons, but can be used to organize any set of controls into logical groups Note: if you need description about other controls, you can check them in the MSForms library in VBE Object Browser

Exercise - Design a User Form In the following, we will design a user form in order to understand how to place, resize, and line up controls on a user form and how to specify or change controls’ properties in the Properties window The resulting user form should look similar to the figure on the right.

Exercise Step 1: Adding Controls to a User Form First, enlarge the user form Click on a control in the Toolbox and then drag and shape it on the form After you add a number of controls, you can select a group of controls (by dragging the mouse over them) and right click on them (or use the Format menu item) to align and resize the controls Step 1.1: Add an explanation label on the top of the user form Step 1.2: Add two command buttons at the top right (“Submit” and “Cancel”) - Press the Ctrl key for copying

Exercise Step 1: Adding Controls to a User Form Step 1.3: Add 2 text boxes and their corresponding labels (which act as prompts for what the user should enter in the box.) Step 1.4: Add a frame and then add 2 option buttons within it Step 1.5: Copy the frame to its right and add 2 more option buttons within the group Step 1.6: Add another frame at the bottom and 4 Check boxes within it Step 1.7: Add a list box to the right of the frame and its corresponding label Step 1.8: resize and align the controls to make them look nicer Now time to make changes to the properties of these control objects …

Control Properties Major properties of user forms and controls –Name property Assigns a name to an object Used by the programmer to refer to an object in VBA code A name can contain letters, numbers, and the underscore character only, must begin with a letter, and must not exceed 40 characters –Caption property Controls what the user sees on screen Usually, you need to change the Name and Caption properties of user forms and some controls. As to other properties of different objects, whether to change them or not depends on the type of object, the application, and the developer’s preferences. To set properties of a control, you need to select the control first, then the Properties window will show the properties for this control. Now, let’s go back to the exercise …

Exercise Step 2: Setting Properties of the Controls Change the user form Name property to “InputsForm” and its Caption property as “Student Record” Top command button: change its Name property to SubmitButton, change its Caption Property to Submit, and change its Default property to True – this gives the Submit button the functionality you expect once the form is operational, so that you can click on it or press the Enter key to do the same thing Bottom command button: change its Name property to CancelButton, change its Caption Property to Cancel, and change its Cancel Property to True – to allow a user to press the Esc key instead of clicking on the Cancel button Top label: click on the label and change the Caption Property (“This user form is for test purpose only.”)

Exercise Step 2: Setting Properties of the Controls Label2 & Label3: Change the Caption property to Name and GPA respectively Text boxes: change the Name property to NameBox and GPABox Frames: change Caption property to “Gender”, “Standings”, and “Hobby” respectively, and rename their Name property as “GenderFrame”, etc. Within the Gender frame: Option buttons: Change the Name properties of the option buttons into MaleOption and FemaleOption, and change their captions to Male and Female. Similarly, within the Standings frame, change Name and Caption properties of the other four option buttons into FreshmanOption, SophomoreOption, Freshman, Sophomore, etc.

Exercise Step 2: Setting Properties of the Controls Check boxes: Change the Name and Caption properties to SportsBox and Sports, MovieBox and Movie, etc List Box: change its Name property to CourseList. It does not have a Caption property, so add a label above it called “Courses Taken” MultiSelect property: –Default: 0-fmMultiSelectSingle (only one items could be selected) –2-fmMultiSelectExtended (more then one items could be selected) – Choose this one in this exercise Tab Order –To allow users to tab from one control to another by pressing the Tab key - change the TabIndex property of each control, starting with index 0 Any control with the TabStop property set to False cannot be tabbed to (e.g., Labels) For frames and its inside option buttons, tabs are set separately (also starting with index 0)

Exercise: Test the User Form Select the user form Run Sub/UserForm – Tab through the controls too Note that you can’t do anything further because the controls are not functional yet. Usually, when a dialog box pops up, it contains some default settings. To do this, we can initialize our user form. Continued…