21/03/20161 2.1 Working with Controls Text and List Boxes.

Slides:



Advertisements
Similar presentations
Lists, Loops, Validation, and More
Advertisements

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
Mouse Tutorial for Win XP In this tutorial you will learn to: Move the mouse Click and double click Make selections Manage windows Use menus Click the.
Stored procedures and views You can see definitions for stored procedures and views in the demo databases but you can’t change them. For views, expand.
Programming with Microsoft Visual Basic th Edition
Using Multiple Forms! Creating a Splash Screen. Uses of Multiple Forms Includes: Dialog Boxes (appear often in Windows Programs) Splash Screen (a window.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
List-based Controls. Slide 2 Introduction There are several controls that work with lists ComboBox ListBox CheckedListBox.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
Create a Narrated Story with PowerPoint. Basics Enter Text. (Click in the text box and start typing. If a text box is not visible, go to Insert > Text.
1 ADVANCED MICROSOFT WORD Lesson 15 – Creating Forms and Working with Web Documents Microsoft Office 2003: Advanced.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
05/09/ Introducing Visual Basic Sequence Programming.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
 What are the different types of loops? ◦ Do….While  Performs statements within loop while a condition is true ◦ Do….Until  Performs statements within.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
IE 411/511: Visual Programming for Industrial Applications
1 ADVANCED MICROSOFT WORD Lesson 16 – Customizing Features Microsoft Office 2003: Advanced.
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Seven More on the Repetition Structure.
Basic Controls & Properties Chapter 2. Overview u VB-IDE u Basic Controls  Command Button  Label  Text Box  Picture Box u Program Editor  Setting.
Copyright © 2001 by Wiley. All rights reserved. Chapter 2: Using Visual Basic to Create a First Project Getting Started with VB Development Environment.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Tutorial 11 Five windows included in the Visual Basic Startup Screen Main Form Toolbox Project Explorer (Project) Properties.
Basic & Advanced Reporting in TIMSNT ** Part Two **
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”
Tutorial 51 Programming Structures Sequence - program instructions are processed, one after another, in the order in which they appear in the program Selection.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Six The Do Loop and List Boxes.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Chapter Two Creating a First Project in Visual Basic.
How to get started with Excel VBA. We need to enable programming in Excel  the “Developer menu”
Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables.
1 Advanced Computer Programming Lab Calculator Project.
Select (drop-down list) Inputs. Insert/Form/List Menu.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
This is the Title slide. To insert a new slide, go to the Insert menu and select New Slide You can select from the slide layout for each new slide used.
AdditionalControls 1. The MenuStrip 2 Double-click Let’s begin to design the menu bar for VB! Let’s begin to design the menu bar for VB! 3.
31/01/ Selection If selection construct.
Unit 6 Repetition Processing Instructor: Brent Presley.
Chapter 27 Getting “Web-ified” (Web Applications) Clearly Visual Basic: Programming with Visual Basic nd Edition.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
Using Option Buttons. Option Buttons Are similar to checkboxes. Must appear in groups. Only one button in the group can be selected at a time. Sometimes.
The Program Editor1 Visual Basic (VB) supports a text editor (not a word processor) that permits the writing and modification of program code. The editor.
CIS 338: Events Dr. Ralph D. Westfall April, 2011.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
1 4.2 Selection Logical Operators. 2 Learning Objectives Explain how the logical operator AND Boolean statements works. Directly testing if text boxes.
CS 281 – Fall 2010 Lab 4 Parametric Query and Forms in MS Access.
Chapter 7 Multiple Forms, Modules, and Menus. Section 7.2 MODULES A module contains code—declarations and procedures—that are used by other files in a.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
26/06/ Iteration Loops For … To … Next. 226/06/2016 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Please wait, Our presentation will be starting soon. Use Alt+Tab key to go to other applications while the presentation is running. Use Esc key to stop.
Dive Into® Visual Basic 2010 Express
Chapter 2: The Visual Studio .NET Development Environment
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Microsoft Excel 2003 Illustrated Complete
CIS 16 Application Development Programming with Visual Basic
Using Templates and Library Items
Group Boxes, Radio buttons and Checked List Boxes
Introduction to Visual Basic 2010
Microsoft Excel 2007 – Level 2
Presentation transcript:

21/03/ Working with Controls Text and List Boxes

221/03/2016 Learning Objectives: Know what the text box and list box controls are used for and how to use them. The difference between a property and a method.

321/03/2016 The Text Box Used for entering and displaying data The Text property is the most common property you will use.

421/03/2016 Methods Controls have properties Properties have methods. A property controls the appearance and behaviour of a control. A method is an action that can be done on a property.

521/03/2016 The Text Box Focus is the most common method you will use. It positions the cursor inside the text box. e.g. txtBox.Focus e.g. txtBox.Focus

621/03/2016 The List Box Used to select one or more items from a list.

Common List Properties PropertiesNotes SelectedItem Contains the selected item. Sorted Specifies whether the items in the list box are sorted or not. Text Contains the currently selected item from the list box. SelectedIndex Contains the index of the selected item. The first item is indexed (numbered) by Visual Basic as 0, the next as 1 and so on.

821/03/2016 Common List Methods MethodsNotes Add Add an item to a list box. Remove Remove an item from a list box. Clear Removes all items from a list box. Count Counts all the items in a list box.

921/03/2016 Program 2.1 A list box of countries Specification: Specification: Allow the user to enter names of countries in a text box. They should be able to click command buttons to display all the names alphabetically in a list box, to delete a selected country from the list box, or to delete all the countries from the list box. Allow the user to enter names of countries in a text box. They should be able to click command buttons to display all the names alphabetically in a list box, to delete a selected country from the list box, or to delete all the countries from the list box.

1021/03/2016 Program 2.1 A list box of countries 1.Create a new project ‘A list box of countries. 2.Change the text property of the form to ‘Using a List Box’. 3.Drag a text box, three command buttons and a list box onto the form and position them as shown.

1121/03/2016 Program 2.1 A list box of countries

ControlProperty Property Setting TextBoxNametxtCountry ButtonNameTextbutAddAdd ButtonNameTextbutDeleteDelete ButtonNameTextbutClearClear ListBoxNameSortedItemslstCountriesTrueSpainUSAAustria

Program 2.1 A list box of countries 1.Double click the Add button to bring up its Click event procedure code template. 2.Write in inside the procedure code template: lstCountries.Items.Add(txtCountry.Text) 3.Return to design view and double click the Delete button. 4.Write in inside the procedure code template: lstCountries.Items.Remove(lstCountries.SelectedIte m)

1421/03/2016 Displaying updated information while a program is running This will normally be done in a label so: lbl LabelName.Text = whatever you want to display lbl LabelName.Text = whatever you want to display If you want to display a standard text message then enclose the text in “…….”. If you want to display a count of the items in a list then lstBoxName.Items. Count

Program 2.1 A list box of countries 1.Return to Design View and double click the Clear button. 2.Write in inside the procedure code template: lstCountries.Items.Clear()

Program 2.1 A list box of countries 1.Run the program 2.Publish the program.

List Boxes For example: lstBoxName.Items.Add( what you want to add ) lstBoxName.Items.Add( what you want to add ) Reading this forwards means: This list box, items of, add (what is in these brackets). This list box, items of, add (what is in these brackets). However, you will that sometimes it is easier to understand VB instructions if you read them backwards. (What is in these brackets) add it to the items of this list box. (What is in these brackets) add it to the items of this list box. lstBoxName.Items.Remove( what you want to remove ) lstBoxName.Items.Remove( what you want to remove ) Similar to above, reading it backwards: (What is in these brackets) remove it from the items of this list box. (What is in these brackets) remove it from the items of this list box. lstBoxName.Items.Count lstBoxName.Items.Count Similar to above, reading it backwards: Count the number of items in this list box. Count the number of items in this list box. 1721/03/2016

List Boxes For example: lstBoxName.Items.Add( textBox.Text ) lstBoxName.Items.Add( textBox.Text ) Adds the contents of a text box to a list box. lstBoxName.Items.Add( lstAnotherListBox.SelectedItem ) lstBoxName.Items.Add( lstAnotherListBox.SelectedItem ) Adds the selected item in another list box to this list box. lstBoxName.Items.Remove( lstBoxName.SelectedItem ) lstBoxName.Items.Remove( lstBoxName.SelectedItem ) Removes the selected item in a list box (from itself). lstBoxName.Items.Count lstBoxName.Items.Count Counts the items in a list box. 1821/03/2016

1921/03/2016 Plenary What are the text box and list box controls used for? Text box controls are used for entering and displaying data. List box controls are used for displaying a list of items from which the user can select an item.

2021/03/2016 Plenary between a property and a method? What is the difference between a property and a method? A property controls the appearance or behaviour of a control. A property controls the appearance or behaviour of a control. A method is an action which can be done on a control and is sometimes done through a property. A method is an action which can be done on a control and is sometimes done through a property.

2121/03/2016 Extension “Trip” Program Build a program using two list boxes as shown:

2221/03/2016 Extension “Trip” Program One list box should be named ‘lstStudents’ and should list all the students in a class. The other list box should be named ‘lstTrip’ and should list those students going on a school trip. Fill (populate) lstStudents before running the program (at design time) using its Items property.

2321/03/2016 Extension “Trip” Program When the program runs the user can click a button to copy the selected name from lstStudents to lstTrip. A second button should let them delete a name from lstTrip and move it back to lstStudents in case they have made a mistake or the student has changed their mind. Display the number of students going on the school trip. See slides 14 & 17 for a hint on how to do this. See slides 14 & 17 for a hint on how to do this.

2421/03/2016 Extension “Trip” Program When running your program be careful not to click either of the two buttons (Add to trip / Delete name) if you have no name selected. If you do the program will fail. You will have to click the Debug menu and click the Stop Debugging option. Then run the program again. You don’t know enough to be able to stop this happening although you are welcome to investigate.

2521/03/2016 Extension “Trip” Program 1.Disable the Delete button at design time so that it is disabled when the program is first run. Enable it only after someone has been added to the trip list. Note that you cannot disable it again without covering selection but you could investigate this as you have covered it in theory but not in practice. 2.Add another label to count the students who are not going on the trip. 3.Use the SelectionMode property to allow the user to select more than one option from the list at a time.