Visual Basic Programming Chapter Six Notes Repetition and the Do Statement ADDING ICONS TO YOUR FORM –It is possible to add an ______________ to your title bar by setting the form’s _________________________________. –You can use the NUMEROUS icons that come with Studio.Net. Of course, if you don’t find any that you like you can always create your own or find some online. –I’ve moved a copy of the icon files that come with Visual Studio.Net into our class network space for your convenience. PROPERTIES OF THE LISTVIEW CONTROL –__________________________ – Determines how items display in the ListView Control. Switch to _______________________ if you would like to display multiple columns. –_________________________ – used to add and edit the Columns in a ListView Control. You can change the Text Property to give each column its own heading. Other settings, like Width, can also be adjusted if necessary. –_________________________ – specifies whether the user can select multiple items in the list. –_________________________ – determines if a check box appears with each item in the list, so the user can select multiple items. ANCHORING CONTROLS –In previous applications we’ve developed the windows used were not resizable during run time. –When a form is resized, controls on the form must be moved or resized as well in order to maintain a usable and balanced user-interface. –Rather than having to code changes for the width, height, and location of every control, VB.NET allows you to set a fixed location, or ___________________, for controls to specified sides of a form. –For example, in the Today’s Sales Check program the buttons were anchored to the bottom of the form, the List View control was anchored to all four sides of the form. ADDING A NEW FORM TO A PROJECT –Most.NET applications contain more than one form… that’s why you should learn how to add new ones to your project, eh? –There are many ways to do it. Here are a couple: You can right-click the on the project name in the Solution Explorer window and then point to Add on the shortcut menu. You can go up to the Project Menu and click on the menu item for adding a new Windows form etc… –If the first form is used to launch the second form it is sometimes referred to as the ________________________. You can change the StartupPosition Property on the new form to _____________________________, meaning that the new form will display in the center of the first form when its launched.
Visual Basic Programming Chapter Six Notes Repetition and the Do Statement CHECKBOX CONTROL –The ____________________________________ is used in applications to allow a user to specify one of two conditions, such as on or off, yes or no, or true or false. In the Today’s Sales Check program the checkbox control was used to input whether an item was on sale or not. –Some important CheckBox Properties: ___________________ – determines whether the box is checked or not. It’s either True or False. ___________________ – puts text next to the CheckBox explaining its purpose. ___________________ – Determines the location of the check box inside of the control. (right of text, left of text etc..) DECLARING AN OBJECT AND USING AN OBJECT VARIABLE –So you have your main form … Today’s Sales Check and the user clicks on the button to Enter Today’s Sales. You want to launch the second form from within the first form. –Well, as is the case with all forms, the Today’s Sales Entry Form is a _____________________, which means that an instance of the class must be declared before it can be used. This can be done with an __________________________________________. –Use the Dim statement and the _________________________. For example: __________________________________________________________________________ DECLARING AN OBJECT AND SHOWING A FORM –The ____________________ determines whether the variable contains a complete instance of the object. If the New keyword is not used, then the variable is declared for future use but no memory is set aside for the contents of the object. If the New Keyword is used, the object is said to be __________________________ & memory is set aside for a complete copy of the object. You can’t use a new form until this is done. FYI: This does not need to be done for the startup form for a project..NET does that for you! –In order to get the form up on the screen you need to call it from memory. One way to do this is with the Show() or ShowDialog() method. SHOW( ) METHOD AND SHOWDIALOG( ) METHOD –If the ________________________________ is used in a form’s code to open another form, then both forms still can receive focus and be accessed by the user. This is called a _____________________________ – meaning that the user can _________________________________________________________________. –The _________________________________________ is used to open a ____________l form. This means that the user must _________________________________________________ ___________________________________________________.
Visual Basic Programming Chapter Six Notes Repetition and the Do Statement REPETITION AND THE DO STATMENT –One of the most powerful aspects of computer programming is the capability of performing a set of operations repeatedly based on certain conditions. –In programming, the process of repeating a set of instructions is known as ________________________, or __________________________. –There are four basic types of loops, two of which contain the decision to terminate the loop at the top of the control structure and two which contain the decision to terminate the loop at the top of the control structure. THE DO WHILE STATEMENT –A common form of the Do statement is the _______________________. –This statement ________________________________________________________________ ____________________________________________________________________________. –Two examples: (one tests at the top of the structure, one tests at the bottom of the structure) ______________________________ ________________________________ _________________________________ ___________________________________ DO UNTIL STATEMENTS –Another common form of the Do statement is the _________________________. –This statement ____________________________________________________. –Two examples: (one tests at the top of the structure, one tests at the bottom of the structure) ______________________________ ________________________________ _________________________________ ___________________________________ SELECTING THE PROPER DO STATEMENT –Your program’s logic should indicate which type of Do Loop to use. (Draw a flowchart if you are having trouble picturing it!) If the decision to terminate is at the top of the loop, _______________________________. If the decision to terminate is at the bottom of the loop, ____________________________. –The loops are interchangeable as long as you make the code match the logic! –An example from our main project: _____________________________________________________
Visual Basic Programming Chapter Six Notes Repetition and the Do Statement WORKING WITH COLLECTIONS –A ___________________________________ is a group of one or more objects that can be accessed and operated on as a single entity. –You have a little bit of experience with collections. In Project 5 you used a collection to add items to your ComboBox. This is using a collection as a property of a control. As you learned in Project 5,.NET assigns an unique __________________________ to each item in a collection. This will come in handy when working with a ListView Control. –Before adding items to the ListView Control you must: Create an object to hold the item Then you must put the user’s input into that object. Then you can add that object to the ListView Control Finally, you can redisplay the Input Form ADDING ITEMS TO A LISTVIEW CONTROL –__________________ – this property always displays as the first column in the ListView Control. –___________________________ – If you have more than one column in a ListView control, a SubItems collection is created. –Each Item and SubItem has an __________________________________________________ ______________________________. –For Example lstTodaysSales.Items(0).Text = _____________________ lstTodaysSales.Items(0).SubItems(1).Text = _____________________ FOR…NEXT STATEMENTS –___________________________________ are different from the Do…Until Loop in that it has an automatic counter and condition built in. –This makes them perfect for ______________________________________ – these are loops where you set up a variable before the loop starts, then increment the variable within the loop, and then test to see if it has reached the maximum count that you’re aiming for. –Benefits of For … Next Loops: ________________________________________ EXAMPLES OF FOR…NEXT STATEMENTS ___________________________________________________________________________________________________ ___________________________________________________________________________________________________ ___________________________________________________________________________________________________ ___________________________________________________________________________________________________ ___________________________________________________________________________________________________
Visual Basic Programming Chapter Six Notes Repetition and the Do Statement EXITING A LOOP PREMATURELY –It is possible to exit a loop early if necessary. Just use the ____________________. –Examples are below: __________________________ NESTED FOR … NEXT LOOPS –When the statements of one For…Next Loop lie within the range of another For…Next Loop, the loops are said to be ________________, or ____________________________. –An example can be seen below: IMPLEMENTING A LOOP WITH A FOR…NEXT STATEMENT –We talked about For…Next Loops being great for controlled-count loops. Here is a perfect example from the btnTotalSales in the Chapter 6 Main Project. This button is used to add to the total for items on sale and items that weren’t on sale. –Line 160 sets the intListCount variable = to the number of items in the ListView Control. The _______________________________________________ of the list box knows exactly how many items are in the control. So use it! –Line 161 and 163 set up the loop. Obviously we’ll have to add code between the For and the Next! ACCESSING ITEMS IN A LISTVIEW CONTROL We’re still looking at the btnTotalSales loop … –In order to add up the sales we need to get the information from that particular column of the ListView Control. How did they do that? –The line of code might look like this: ________________________________________________________________________ –Breaking down this code: We need to type in the name of the ListView Control Go to the particular items property index # that we are currently working on Then access the actual Sales Total from the SubItems column We’re saving the results of this into StrItemSales since text properties are strings. STRING MANIPULATION The ______________________________________________ allows you to retrieve part of a string (from a larger string) based on a start position and the number of characters to retrieve. For example: strExample = “Christy Garrett” strLastName = ____________________________ ( ___, ___) There are a ton of other ways to manipulate strings in.Net. They are listed on page 6.63 in your text book. For example: In the main project we had $’ s in the Total Sales column of the ListView Control. Those dollar signs would’ve messed up our ability to total up those sales figures. We replaced those $ with 0’s in the code so we could add them up by using the __________________:
Visual Basic Programming Chapter Six Notes Repetition and the Do Statement CONCATENATION OPERATORS –We learned how to concatenate strings in Chapter Four. –Concatenation Operators are another form of concatenation. It is used to save you time when you are typing up expressions. –For Example: ___________________________________ can be written as ___________________________________ –______________________________________________ -- used to start a new line within a string. REMOVING ITEMS FROM A LISTVIEW CONTROL –It is very easy to clear an entire list box. Just use the _______________________________. –For example, this code was found inside the btnClearList click event: ________________________________________________________ –Other methods such as Remove() or Remove At() can be used to remove specific items from the list. KEYBOARD EVENTS –This program wanted the user to be able to delete any item from the ListView Control simply by clicking on the item and then pressing the Delete key. –In order to do that you would have to set up a KeyBoard event for the ListView Control. This is very simple to do! –Most controls include three event procedures for handling user input from the keyboard. –The _______________________________, the ____________________________, and the ___________________________ occur when the user presses a key when the control has focus. –The code below is an example of using a KeyDown event and the Replace() method to remove a selected item from the list. CODING A FORM RESIZE EVENT –The ____________________________ occurs when a form or control first displays or when the size changes because the user resizes the form. –Code in the Resize event is often used to ensure that the user interface ____________________ _____________________________________________________________________________. –Since the Resize event isn’t the default event for the form, you must switch to this event before you can write the code. –Let’s look at the code for the Resize event and make sure you understand it! THE ME KEYWORD –You’ll notice the use of the Me Keyword in this and other sections of code in Project 6. –This is another brilliant shortcut from the people at Microsoft. When coding a form, you’ll often find the need to refer to the current form. –The _________________________ allows you to reference the form’s name without having to type it out each time. Me is whichever form you’re currently on. –For example: ____________________________________________________________ __________________________________________________________________________ SETTING THE STARTUP PROJECT –As you have seen, when you start a new Windows project in VB.NET it creates a form called Form1. By default, the _____________________________________________________. –When working with multiple forms or when you’ve renamed a form, you must tell Visual Basic which form to display first when you hit run. This can be done from the ______________________. –There is more than one way to get to this screen. Make sure you know one of them!
Visual Basic Programming Chapter Six Notes Repetition and the Do Statement Use the note space below for the following Coding 201 topics: –Do … While and Do… Until Statements –For … Next Statement –String Manipulation –Concatenation Operators _________________________________________________________________
Visual Basic Programming Chapter Six Notes Repetition and the Do Statement