© 1999, by Que Education and Training, Appendix A, pages 735-744 of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.

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.
Chapter 6: The Repetition Structure
Programming with Microsoft Visual Basic 2008 Fourth Edition
Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
List box & Combo box controls School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 14, Monday 4/21/2003)
1 Visual Basic Programming II Lecture 3 MIS233 Instructor – Larry Langellier.
1 Lab6 Lab6 ComboBox Control Properties, Methods and Events.
Using String Functions Left(str, nchars) - extract left nchars Right(str, nchars) - extract right nchars Mid(str,start,[nchars]) - get middle chars.
Lab4 ListBox Control Properties, Methods and Events.
VB Default Controls List Box, Combo Box
Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 1 Lab5 ListBox Control Properties, Methods and Events.
Repeating Program Instructions Chapter Microsoft Visual Basic.NET: Reloaded 1.
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.
Chapter 8 Using Repetition with Loops and Lists. Class 8: Loops and Lists Write Do loops to execute statements repeatedly Write For loops to execute statements.
© 1999, by Que Education and Training, Chapter 7, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Tutorial 7: Sub and Function Procedures1 Tutorial 7 Sub and Function Procedures.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
© 1999, by Que Education and Training, Chapter 5, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Ch 11: Userforms CP212 Winter Topics Designing User Forms o Controls Setting Properties o Tab Order o Testing Writing Event Handlers o Userform_Initialize.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
1 Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops 6.3 List Boxes and Loops.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Chapter 7 Code Tables. VB Code Box 7-1 Event Procedure for Compute Button Private Sub hsbExemptions_Change() txtExemptions.Text =Str(hsbExemptions.Value)
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.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Seven More on the Repetition Structure.
6.3 List Boxes and Loops Some Properties, Methods, and Events of List Boxes List Boxes Populated with Strings List Boxes Populated with Numbers Searching.
MAT Meyer Week 2 Programming VB: ‘basics’ Review & preview: Events, variables, statements, etc. Images, Control arrays, For/Next Assignment: read.
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)
Working with option button, check box, and list box controls Visual Basic for Applications 13.
© 1999, by Que Education and Training, Chapter 8, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
1 Week 6 The Repetition Structure. 2 The Repetition Structure (Looping) Lesson A Objectives After completing this lesson, you will be able to:  Code.
Chapter 6: The Repetition Structure
Tutorial 6 The Repetition Structure
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Six The Do Loop and List Boxes.
Class 3 Remote Instruction Computer Math EDU 556 Programming for Instruction Dr. Steve Broskoske This is an audio PowerCast. Make sure your volume is.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
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.
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 -
Two Forms Please use speaker notes for additional information!
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.
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.
Chapter 8.  Visual Basic includes several built-in mathematical functions ◦ Abs ◦ Sqr ◦ Sgn ◦ IsNumeric ◦ Round ◦ Format ◦ Pmt ◦ PV ◦ FV.
7-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code that may be executed several times. Fixed-count (definite) loops repeat a fixed.
Visual Basic.NET BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings.
List Boxes and Combo Boxes Provides a list of items to select from Various styles — choose based on Space available Need to select from an existing list.
Unit 6 Repetition Processing Instructor: Brent Presley.
Arrays Chapter 6. Objectives learn about arrays and how to use them in Java programs learn how to use array parameters and how to define methods that.
IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked.
Using a Database Access97 Please use speaker notes for additional information!
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.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code (loop body) that may be executed several times. Fixed-count (definite) loops repeat.
5a – While Loops Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
21/03/ Working with Controls Text and List Boxes.
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 9: Chapter 5: Slide 1 Unit 9 Do Until and For… Next Loops Chapter 5 Lists,
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
Microsoft Visual Basic 2008: Reloaded Third Edition
A variable is a name for a value stored in memory.
Department Array in 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.
Introduction to Problem Solving and Control Statements
Data Types List Box Combo Box Checkbox Option Box Visual Basic 6.0
Presentation transcript:

© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach Combo Boxes & List Boxes n List Box i User selects from predefined set of textual choices i Index number of the user’s selection is stored in ListIndex property i There is no Text property! i List property is used to show current list item selected i ListCount property is equal to the number of items in the list box n Combo Box i User selects from predefined set of textual choices or enters own textual response i Selected response is assigned to Text property i Style property determines whether list will also have textbox or not as well as whether list will drop down or not Each item in list has an index value, starting at 0 for the first item

© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach Filling a list n Design time i List property 1)Type entry 2)Press Ctrl-Enter 3)Type next entry 4)Repeat 2 & 3 above until last entry has been added 5)Press ENTER or click anywhere else to complete the operation n In code i AddItem method Call lstEx.AddItem(“Apple”) Call lstEx.AddItem(“Banana”) Call lstEx.AddItem(“Carrot”) Call lstEx.AddItem(“Donut”) Call cboEx.AddItem(“Ape”) Call cboEx.AddItem(“Bear”) Call cboEx.AddItem(“Cat”)

© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach Removing individual list items n Design time i List property 1)Highlight only the individual item to be deleted 2)Press DELETE 3)Press ENTER or click anywhere else to complete the operation n In code i RemoveItem method u Call lstEx.RemoveItem(0) –will remove first item from list u Call cboEx.RemoveItem(3) –will remove fourth item from list u Index values of list items is updated

© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach Clearing a list n Design time i List property 1)Highlight entire selection 2) Press DELETE key to erase all items in list n In code i Clear method Assume lstEx has four items (Apple, Banana, Carrot, and Donut), and cboEx has three items (Ape, Bear, Cat) Call lstEx.Clear Call cboEx.Clear will erase all contents of the list box lstEx and the combo box cboEx

© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach Selecting/deselecting from lists n ListIndex property identifies which list item is selected (highlighted) n Controlling list selection at design time or in code i Select first list item by assigning 0 to ListIndex i Select another list item by assigning the corresponding position number to ListIndex i Deselect all items by assigning -1 to ListIndex

© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach Sorting lists n Sorted property i Boolean value that represents whether list items are displayed in sorted order or not n What is we wanted to preserve the original order? i ItemData property can be used to hold the original order of the list i lstName.ItemData(IndexLocation) = Value

© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach List Example Private Sub cmdAdd_Click() Call lstEx.AddItem(txtEx.Text & vbTab & _ Format(lstEx.ListCount, "00")) lstEx.ItemData(lstEx.NewIndex) = lstEx.ListCount - 1 Call lstEx2.AddItem(txtEx.Text & vbTab & _ Format(lstEx2.ListCount, "00")) lstEx2.ItemData(lstEx2.NewIndex) = lstEx2.ListCount - 1 txtEx.SelStart = 0 txtEx.SelLength = Len(txtEx.Text) End Sub Private Sub cmdOriginal_Click() lstEx.Visible = False lstEx2.Visible = True lstEx3.Visible = False End Sub Private Sub cmdSort_Click() lstEx.Visible = True lstEx2.Visible = False lstEx3.Visible = False End Sub

© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach List Example Private Sub cmdItemData_Click() Dim ListLoc As Integer Call lstEx3.Clear For ListLoc = 0 To lstEx2.ListCount - 1 Step 1 Call lstEx3.AddItem(lstEx2.List(lstEx2.ItemData(ListLoc))) Next ListLoc lstEx.Visible = False lstEx2.Visible = False lstEx3.Visible = True End Sub

© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach Counting items in list n Sometimes the number of list items is not determined at design time, but the program needs to know the total number of items in a list. n ListCount property stores the current number of items in a list n ListCount is always equal to 1 plus the highest ListIndex n TotalItems = lstEx.ListCount

© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach For-Next Loops for Lists Dim LCount As Integer For LCount = 0 To (lstEx.ListCount-1) Step 1 Printer.Print lstEx.List(LCount) Next LCount steps to process after loop ends False True Steps to process after loop ends Print current list item LCount > location of last list item? LCount = 0 LCount = LCount + 1 What changes are needed to print the list items in reverse order? What processing is needed to find the total of list items? The minimum? The maximum?