List box & Combo box controls School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 14, Monday 4/21/2003)

Slides:



Advertisements
Similar presentations
Working with Intrinsic Controls and ActiveX Controls
Advertisements

Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
1 Visual Basic Programming II Lecture 3 MIS233 Instructor – Larry Langellier.
1 Lab6 Lab6 ComboBox Control Properties, Methods and Events.
Creating Custom Forms. 2 Design and create a custom form You can create a custom form by modifying an existing form or creating a new form. Either way,
Flowchart Start Input weight and height
Lab4 ListBox Control Properties, Methods and Events.
VB Default Controls List Box, Combo Box
CVEV 118/698 Visual Basic Lecture 3 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar.
Introduction to Computing Dr. Nadeem A Khan. Lecture 11.
Introduction to computers & Visual Basic School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 3, Monday 1/27/2003)
Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 1 Lab5 ListBox Control Properties, Methods and Events.
Introduction to Visual Basic What it is, and a simple program Mike Thelwall University of Wolverhampton, UK.
Lec4 P 1 CP2030 Visual Basic For C++ Programmers Copyright © University of Wolverhampton CP2030 VBFC Lecture 4 Back To Index v Iteration - Looping v Arrays.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Ch 11: Userforms CP212 Winter Topics Designing User Forms o Controls Setting Properties o Tab Order o Testing Writing Event Handlers o Userform_Initialize.
Array Processing: Exercises School of Business Eastern Illinois University © Abdou Illia, Spring 2002 (Week 10, Friday 3/28/2003)
Appendices A - F A-F Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
Creating your own form from scratch.. To create a custom form, you can modify an existing form or design and create a form from scratch. In either case,
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.
Mouse Events. Mouse Driven Events Unlike control_click() which is passed no arguments (unless it's an index for an array), MouseDown, MouseUp and MouseMove.
Database Management School of Business Eastern Illinois University © Abdou Illia, Fall 2002 (Week 16, Monday 12/09/2002)
Chapter 2 - More Controls More controls – Text boxes - used for user input – Frames - containers to group items – check boxes - user select an option -
Copyright © 2001 by Wiley. All rights reserved. Chapter 5: The Repetition Process in Visual Basic Event Driven Loops Determinate Loops Indeterminate Loops.
The Repetition Process in Visual Basic. The Repetition Process The capability to repeat one or more statements as many times as necessary is what really.
Chapter 9 - VB.Net by Schneider1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes, Combo Boxes, and the File-Opening Control The List Box Control.
ListBox, ComboBox, Menu Chapter 5.4, ComboBox Control: Properties & Methods u Combines TextBox features with a short drop- down list  cboOne.AddItem(string)
1. Chapter 4 Customizing Paragraphs 3 More Paragraph Changes Highlight a paragraph in Word by applying borders and shading. Sort paragraphs to control.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
§Visual - A method used to create GUI applications. §BASIC - Beginner’s All - purpose Symbolic Instruction Code developed by John Kemeny. §VB- Evolved.
VB Games: Preparing for Memory Brainstorm controls & events Parallel structures (again), Visibility, LoadPicture, User-defined procedures, Do While/Loop,busy.
Working with option button, check box, and list box controls Visual Basic for Applications 13.
© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 17 – Flag Quiz Application Introducing One-Dimensional.
Visual Basic Games: Week 4 Recap Parallel structures Initialization Prepare for Memory Scoring Shuffling Homework: when ready, move on to next game/chapter.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Sequential files School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 12, Monday 4/07/2003)
Chapter 7 P 1 Lists and Loops List boxes and combo boxes List box - list of items - useful for a list which does not change Combo box - list of items -
Integrated Development Environment Visual Basic IDE Slide 2 of 10 Topic & Structure of the lesson Introduction Integrated Development Environment Tool.
Chapter 7 - Lists, loops and printing w List boxes and combo boxes several types can add items at design time or during run time user select from predefined.
VB Objects & Events (Exercises) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 3, Friday 1/31/2003)
1 Visual Basic Part I - A tool for customizing your program Principles of GIS
Review for Final (Part 2) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 15, Friday 5/2/2003)
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Controls. Common properties Height – Height of the control Left – Left of the control Width – width of a control Top - From the screen top Font – Foreground.
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.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked.
Basic GUI VISUAL BASIC. BASIC GUI Slide 2 of 53 Topic & Structure of the lesson Introduction Data Validation Use controls for making choices Write Pull.
TOOLBOX. The Toolbox Intrinsic Controls - always included in the Toolbox ActiveX Controls - separate files with ocx file extension Insertable Objects.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
21/03/ Working with Controls Text and List Boxes.
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.
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
The Advantage Series ©2005 The McGraw-Hill Companies, Inc. All rights reserved Chapter 12 Introducing Visual Basic for Applications Microsoft Office Excel.
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Introduction to Computing
Apply Procedures to Develop Menus, List Box and Combo Box Objects
VB 6.0.
Visual Basic.
The List Box Control Items can be placed into the list at design time or run time The Sorted property causes items in the list to be sorted automatically.
P.J.Balakumaran, AP, Commerce CA, SNMV CAS
Chapter 4 Enhancing the Graphical User Interface
Chapter 4 Enhancing the Graphical User Interface
Presentation transcript:

List box & Combo box controls School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 14, Monday 4/21/2003)

2 List box, Combo box ? Pointer Label Frame Check Box Combo Box Horizontal Scroll Bar Timer Directory List Box Shapes Image Box Object Linking Embedding Picture Box Text Box Command Button Option Button List Box Vertical Scroll Bar Drive List Box File List Box Lines Data Tool The Toolbox List box with scroll bar List box without scroll bar Dropdown Combo box Simple Combo box

3 Typical use of List and Combo boxes

4 List box control n Displays a list of items from which the user can select one or more. n If the number of items exceeds the number that can be displayed, a scroll bar is automatically added n Common properties: – List Array of items in the list box (Note: index=0 through n) – Sorted True or False (items in alphabetical order) – Multiselect (0, 1 or 2 for No-multiple, Simple-Multiple or Multiple selection) – Text Returns item currently highlighted Examples: lstEmployee.Multiselect = 2 lstEmployee.Sorted = True lstEmployee.List(0) = “John” picOutput.Print lstEmployee.Text

5 List box control n Common Methods: – AddItem item Adds the item referred to as item to the list – RemoveItem n Removes the item of index n from the list box – Clear Deletes all items in the list box – ListCount Returns the # of items in the list box – ListIndex Returns the index of the item currently highlighted in the list box. – NewIndex Returns the index of the most recently added item Examples: – lstEmployee.AddItem “John” – lstEmployee.RemoveItem 2 – lstEmployee.Clear – NumberOfEmployees = lstEmployee.ListCount – picOutput.Print lstEmployee.NewIndex

6 Private Sub Form_Load() lstEmployee.AddItem "Barbara Lewis" lstEmployee.AddItem "John Whashington" lstEmployee.AddItem "Tom Davis" lstEmployee.AddItem "Nathalie Melrose" End Sub Private Sub cmdAdd_Click() Dim item As String item = InputBox("Employee name be to Add:") lstEmployee.AddItem item End Sub Private Sub lstEmployee_Click() picSelected.Cls picSelected.Print "The selected Employee is" picSelected.Print Chr(34) & lstEmployee.Text & Chr(34) & "." End Sub Private Sub LstEmployee_DblClick() lstEmployee.RemoveItem lstEmployee.ListIndex End Sub List box: Example

7 List box: Exercise Suppose that the list box lstEmployee is as shown and determine the effect of the code. (Assume the Sorted property is set to True) n picOutput.Print lstEmployee.Text n Answer: n picOutput.Print lstEmployee.List(2) n Answer: n lstEmployee.AddItem “Dan Kelli” n Answer: n lstEmployee.RemoveItem 0 n Answer:

8 List box: Exercise Suppose that the list box lstEmployee is as shown and determine the effect of the code. (Assume the Sorted property is set to True) n lstEmployee.AddItem “Dan Kelli” picOutput.Print lstEmployee.NewIndex n Answer: n For n = 0 To lstEmployee.ListCount – 1 lstEmployee.RemoveItem n Next n n Answer:

9 Combo box control n A Combo box control combines the features of a Text box control and a List box control – Users can enter information in the text box portion or select an item from the list box portion of the control. n Combo boxes and List boxes have essentially the same – properties – Events – and methods

10 Combo box control n Common properties: – List Array of items in the list box (Note: index=0 through n) – Sorted True or False (displaying items in alphabetical order) – Style 0 (Dropdown Combo). Includes a drop-down list and a text box. 1 (Simple Combo). Includes a text box and a list, which doesn't drop down. – Text Returns item currently highlighted Examples: cboEmployee.List(0) = “John” cboEmployee.Sorted = True cboEmployee.Style = 1 picOutput.Print cboEmployee.Text

11 Combo box control n Common Methods: – AddItem item Adds the item referred to as item to the list – RemoveItem n Removes the item of index n from the combo box – Clear Deletes all items in the combo box – ListCount Returns the # of items in the combo box – ListIndex Returns the index of the item currently highlighted in the combo box. – NewIndex Returns the index of the most recently added item Examples: – cboEmployee.AddItem “John” – cboEmployee.RemoveItem 2 – cboEmployee.Clear – NumberOfEmployees = cboEmployee.ListCount – picSelected.Print cboEmployee.NewIndex

12 Combo box: Exercise Suppose that the combo box cboEmployee appears as shown and that the Sorted property is set to True. Give a statement or statements that carry out the stated task. n Display the item “Barbara Lewis” in picOutput n Answer: n Display the item “John Whashington” in a picOutput n Answer: n Delete the item “Nathalie Melrose” n Answer:

13 Combo box: Exercise Suppose that the combo box cboEmployee appears as shown and that the Sorted property is set to True. Give a statement or statements that carry out the stated task. n Add the item “Liza Frulla”. Where will it be inserted? n Answer: n Delete every item beginning with the letter “M”. Use a Do While loop and an If test. n Answer: n Suppose that you should use For..Next instead of Do While, give the correct statements. n Answer

14 DriveList box control n A DriveListBox control: – Displays a list of all the valid drives on the computer – Enables a user to select a valid disk drive at run time. n No code is needed to load a DriveList box n Most used property: – DriveContains the name of the currently selected drive Example: Drive = drvExample.Drive n Most used Event – ChangeHappens when the user or program changes the drive selection Example: Private Sub drvExample_Change() picOutput.Print “The New drive is ”; drvExample.Drive End Sub

15 DirList box control n A DirList Box control: – Displays an ordered, hierarchical list of directories and subdirectories n Most used property: – PathContains the current directory path Example: Path = dirExample.Path n Most used Event – ChangeHappens the directory selection is changed Example: Private Sub dirExample_Change() picOutput.Print dirExample.Path End Sub

16 FileList box control n A FileList Box control: – Locates and lists files in the directory specified by the Path property at run time n Most used properties: – FileNameContains the current selected file name – ListCountNumber of files listed – ListArray of file names in the list box – PathContains the current directory path – PatternContains a string that determine which files will be displayed (Example: *.doc only displays files with the.doc extension) n Most used Events – DblClick Happens whenever a file name is double-clicked. – PathChange Happens whenever the path changes Example: Private Sub filExample_ PathChange () picOutput.Print filExample.Path End Sub

17 Synchronizing Drive, Directory and File list boxes n Drive, Directory, and File list boxes are almost always used together to obtain a file name. – As such, it is important that their operation be synchronized to insure the displayed information is always consistent. n When the directory selection is changed (directory box Change event), you should update the displayed file names. Private Sub dirExample_Change() filExample.Path = dirExample.Path End Sub n When the drive selection is changed (drive box Change event), you should update the directory path Private Sub drvExample_Change() dirExample.Path = drvExample.Drive End Sub