CSC_CP_Reviewer_23-24 PDF

Summary

This document provides notes on Computer Programming III (.NET Technology), specifically focusing on Visual Basic controls like RadioButtons, CheckBoxes, ListBoxes, and ComboBoxes. It also covers control structures, including loops, and data structures like arrays and subscripts. These notes are intended as a reviewer for a senior high school class.

Full Transcript

Computer Programming III (.net Technology) The Checked property of the radio button is used to set the state of a radio button. You can...

Computer Programming III (.net Technology) The Checked property of the radio button is used to set the state of a radio button. You can display text, image or both on radio button control. Week 1: Visual Basic Controls: Radiobutton and You can also change the appearance of the radio CheckBox button control by using the Appearance property. Properties of the RadioButton Control: CheckBox 1.) Appearance – sets a value determining the The CheckBox control allows the user to set appearance of the radio button. true/false or yes/no type options. The user can 2.) AutoCheck – sets a value indicating select or deselect it. When a check box is selected whether the Checked value and the it has the value True, and when it is clear, it holds appearance of the control automatically the value False. change when the control is clicked. The Checkbox control has three states, 3.) CheckAlign – sets the location of the check checked, unchecked, and indeterminate. In the box portion of the radio button. indeterminate state, the check box is grayed out. 4.) Checked – sets a value indicating whether To enable the indeterminate state, the ThreeState the control is checked. property of the check box is set to be True. 5.) Text – sets the caption for a radio button. 6.) TabStop – sets a value indicating whether a Properties of the CheckBox Control: user can give focus to the RadioButton 1.) Appearance – sets a value determining the control using the TAB key. appearance of the check box. 2.) AutoCheck – sets a value indicating Methods of the RadioButton Control: whether the Checked or the CheckedState 1.) PerformCilck – generates a Click event for value and the appearance of the control the control, simulating a click by a user. automatically change when the check box is selected. Events of the RadioButton Control: 3.) CheckAlign – sets the horizontal and vertical 1.) AppearanceChanged – occurs when the alignment of the check mark on the check value of the Appearance property of the box. RadioButton is changed. 4.) Checked – sets a value indicating whether the check box is selected. 2.) CheckedChanged – occurs when the 5.) CheckState – sets the state of a check box. 6.) Text – sets the caption of check box. value of the Checked property of the 7.) ThreeState – sets a value indicating whether RadioButton is changed. or not a check box should allow three check states rather than two. Week 2: Visual Basic Controls: Listbox and Methods of the CheckBox Control: Combobox 1.) OnCheckedChanged – raises the CheckedChanged event. ListBox 2.) OnCheckStateChanged – raises the The ListBox represents a Windows control to display CheckStateChanged event. a list of items to a user. A user can select an item 3.) OnClick – raises the OnClick event. from the list. It allows the programmer to add items at design time by using the properties window or at Events of the CheckBox Control: the runtime. 1.) AppearanceChanged –occurs when the value of the Appearance property of the Properties of the ListBox Control check box is changed. 1.) AllowSelection – gets a value indicating 2.) CheckedChanged – occurs when the value whether the ListBox currently enables of the Checked property of the CheckBox selection of list items. control is changed. 2.) BorderStyle – sets the type of border drawn 3.) CheckStateChanged – occurs when the around the list box. value of the CheckState property of the 3.) ColumnWidth – sets the width of columns CheckBox control is changed. in a multicolumn list box. RadioButton 4.) HorizontalExtent – sets the horizontal The RadioButton control is used to provide a set of scrolling area of a list box. mutually exclusive options. The user can select one 5.) HorizontalScrollBar – sets the value radio button in a group. If you need to place more indicating whether a horizontal scrollbar is than one group of radio buttons in the same form, displayed in the list box. you should place them in different container 6.) ItemHeight – sets the height of an item in controls like a GroupBox control. the list box. 7.) Items – gets the items of the list box. ComboBox 8.) MultiColumn – sets a value indicating The ComboBox control is used to display a drop- whether the list box supports multiple down list of various items. It is a combination of a columns. text box in which the user enters an item and a 9.) ScrollAlwaysVisible – sets a value indicating drop-down list from which the user selects an item. whether the vertical scroll bar is shown at all times. Properties of the ComboBox Control 10.) SelectedIndex – sets zero-based index of 1.) AllowSelection – gets a value indicating the currently selected item in a list box. whether the list enables selection of list 11.) SelectedIndices – gets a collection that items. contains the zero-based indexes of all 2.) AutoCompleteCustomeSource – sets a currently selected items in the listbox. custom System.Collections 12.) SelectedItem – sets the currently selected.Specialized.StringCollection to use when item in the list box. the AutoCompleteSourceproperty is set to 13.) SelectedItems – gets a collection CustomSource. containing the currently selected items in 3.) AutoCompleteMode – sets an option that the list box. controls how automatic completion works 14.) SelectedValue – sets the value of the for the ComboBox. member property specified by the 4.) AutoCompleteSource – sets a value ValueMember property. specifying the source of complete strings 15.) SelectionMode – sets the method in which used for automatic completion. items are selected in the list box. This 5.) DataBindings – gets the data bindings for property has values – the control.  None 6.) DataManager – gets the CurrencyManager  One associated with this control.  MultiSimple 7.) DataSource – sets the data source for this  MultiExtended ComboBox. 16.) Sorted – sets a value indicating whether the 8.) DropDownHeight – sets the height in pixels items in the list box are sorted of the drop-down portion of the alphabetically. ComboBox. 17.) Text – searches for the text of the currently 9.) DropDownStyle – sets a value specifying selected item in the list box. the style of the combo box. 18.) TopIndex – sets the index of the first visible 10.) DropDownWidth – sets the width of the of item of a list box. the drop-down portion of a combo box. 11.) DroppedDown – sets a value indicating Methods of the ListBox Control whether the combo box is displaying its 1.) BeginUpdate – prevents the control from drop-down portion. drawing until the EndUpdate method is 12.) FlatStyle – sets the appearance of the called, while items are added to the ListBox ComboBox. one at a time. 13.) ItemHeight – sets the height of an item in 2.) ClearSelected – unselects all items in the the combo box. ListBox. 14.) Items – gets an object representing the 3.) EndUpdate - Resumes drawing of a list box collection of the items contained in this after it was turned off by the BeginUpdate ComboBox. method. 15.) MaxDropDownItems – sets the maximum 4.) FindString – finds the first item in the ListBox number of items to be displayed in the that starts with the string specified as an drop-down part of the combo box. argument. 16.) MaxLength – sets the maximum number of 5.) FindStringExact – finds the first item in the characters a user can enter in the editable ListBox that exactly matches the specified area of the combo box. string. 17.) SelectedIndex – sets the index specifying 6.) GetSelected – returns a value indicating the currently selected item. whether the specified item is selected. 18.) SelectedItem – sets currently selected item 7.) SetSelected – selects or clears the selection in the ComboBox. for the specified item in a ListBox. 19.) SelectedText – sets the text that is selected 8.) OnSelectedIndexChanged – raises the in the editable portion of a ComboBox. SelectedIndexChanged event. 20.) SelectedValue – sets the value of the 9.) OnSelectedValueChanged – raises the member property specified by the SelectedValueChanged event. ValueMember property. 21.) SelectionLength – sets the number of Events of the ListBox Control characters selected in the editable portion 1.) Click – occurs when a list box is selected. of the combo box. 2.) SelectedIndexChanged – occurs when the 22.) SelectionStart – sets the starting index of SelectedIndex property of a list box is text selected in the combo box. changed.  Do Loop – it repeats the enclosed block of 23.) Sorted – sets a value indicating whether the statements while a Boolean condition is True or items in the combo box are sorted. until the condition becomes True. It could be 24.) Text – sets the text associated with this terminated at any time with the Exit Do control. statement.  For…Next – it repeats a group of statements a Methods of the ComboBox Control specified number of times and a loop index 1.) BeginUpdate – prevents the control from counts the number of loop iterations as the loop drawing until the EndUpdate method is executes. called, while items are added to the combo  For Each…Next – it repeats a group of box one at a time. statements for each element in a collection. This 2.) EndUpdate – resumes drawing of a combo loop is used for accessing and manipulating all box, after it was turned off by the elements in an array or a VB.Net collection. BeginUpdate method.  Nested Loops – you can use one or more loops 3.) FindString – finds the first item in the combo inside any another While, For or Do loop. box that starts with the string specified as an argument. Loops 4.) FindStringExact – finds the first item in the When writing computer software, you often need to combo box that exactly matches the perform the same task several times to get the specified string. effect you want. For example, you might need to 5.) SelectAll – selects all the text in the editable create a telephone bill for all customers or read in area of the combo box. ten files from your computer’s disk. To accomplish this, you use a loop, and in this section you’ll take a Events of the ComboBox Control look at the two main types of loops available in 1.) DropDown – occurs when the drop-down Visual Basic 2015: portion of a combo box is displayed.  Do Loops: These loops keep running until a 2.) DropDownClosed – occurs when the drop- certain condition is reached (for example, until down portion of a combo box is no longer all the data is processed). visible.  For Loops: These loops occur a certain number 3.) DropDownStyleChanged – occurs when the of times (for example, exactly ten times). DropDownStyle property of the ComboBox has changed. Do…Loop 4.) SelectedIndexChanged – occurs when the The other kind of loop you can use is one that keeps SelectedIndex property of a ComboBox happening until a certain condition is met. This is control has changed. known as a Do...Loop, and there are a number of 5.) SelectionChangeCommitted – occurs when variations. the selected item has changed and the Use the Do Loop when you want the change appears in the combo box. program to keep running until a certain condition is reached (for example: until all data is processed). Week 3: Control Structure – Looping (The “Do Loop”) The two forms of Do Loop are Pre-Test and Post-Test. Looping is a group of computer instructions that  Do Until…Loop [Pre-Test] may be repeated over and over until a condition is A Do Until...Loop keeps running the loop until the satisfied and then go out of the loop and execute given condition is met. When you use this type the next instruction after the loop. of loop, there isn’t a control variable per se; instead you have to keep track of the current A loop statement allows us to execute a statement position of the loop. or group of statements multiple times and following  Do…Loop Until [Post-Test] is the general form of a loop statement in most of A Do...Loop Until post-test will execute the the programming languages. instructions within the loop once. The program will exit the loop until the Boolean expression becomes True; otherwise, it will continue to loop. Do While…Loop [Pre-Test] The conceptual opposite of a Do Until...Loop is a Do While...Loop. This kind of loop keeps iterating while a particular condition is True. Do…While Loop [Post-Test] Do…While Loop post-test will execute the instructions first before checking the condition. If the condition is true, the loop will be repeated; otherwise, the program will go out of the loop and execute the next instruction after the loop. The post-test loop will Second step: Condition in for loop is execute the instructions within the loop at least evaluated on each loop iteration, if the once. condition is true then the statements inside for loop body gets executed. Once the Quitting Do…Loops condition returns false, the statements in for You can quit a Do...Loop in more or less the same loop do not execute and the control gets way, as you see in the next example program. transferred to the next statement in the program after for loop. Week 4: Control Structure – Looping (The “For Loop”, Nested Loop, and Infinite Loop) Third step: After every execution of for loop’s body, the increment/decrement part of for Initialization – the process of locating and using the loop executes that updates the loop defined values for variable data that is used by a counter. computer program. Fourth step: After third step, the control jumps to second step and condition is re- Iteration – the repetition of a process; a sequence evaluated. of instructions that is continually repeated; There are different types of iterations: Note: The steps from second to fourth 1. Iterate until a certain condition is reached repeats until the loop condition returns false. 2. Iterate a certain number of times 3. Iterate through elements in a list or array B. For…Next Loop – the simplest loop to understand is the For...Next loop. Use In most programs, Increment Operators are used to For...Next loop if you want a statement in a increase the value of the variable by one while loop repeated several times. However, Decrement Operators are used to decrease the For...Next loop only works with numeric value of the variable by one. However, in Visual values (no string and data type). Basic (particularly in for), a Step Number is used. Elements of For…Next Loop: 1. For and Next statement. Condition – statement that is created by the 2. Loop index determines the number of programmer which evaluates actions in the times the statement in the loop will program and evaluates if it is true or false. execute.  Do Loop – it repeats the enclosed block of Counter is the control variable and is usually statements while a Boolean condition is True or a whole number/ integer. until the condition becomes True. It could be terminated at any time with the Exit Do Data type is the data type of the counter statement. and is required if the counter was not  For...Next – it repeats a group of statements a previously declared. specified number of times and a loop index counts the number of loop iterations as the loop Start is the initial value of the counter and executes. should be a number.  For Each…Next – it repeats a group of statements for each element in a collection. This End is the last value of the counter. loop is used for accessing and manipulating all elements in an array or a VB.Net collection. Step number is the amount of increment (if  Nested Loops – you can use one or more loops positive number is used) or decrement (if inside any another While, For or Do loop. negative number is used) of the counter. If this is left blank, the default increment of A loop is used for executing a block of statements one is used. repeatedly until a particular condition is satisfied. For example, when you are displaying numbers C. Using the For…Next Loop from 1 to 100 you may want to set the value of a variable to 1 and display it 100 times, increasing its value by 1 on each loop iteration. D. Using the Step Keyword – you don’t have to start your loop at 1; you can pick any value A. Flow of Execution of the For Loop – as a you want. Nor do you have to increment program executes, the interpreter always the control value by 1 on each iteration; keeps track of which statement is about to again, you can increment by any value you be executed. We call this the control flow, want. or the flow of execution of the program. E. Looping Backwards – By using a Step value First step: In for loop, initialization happens that’s less than 0 (or a negative number), first and only once, which means that the you can make the loop go backward, initialization part of for loop only executes once. rather than forward, as demonstrated in the array of variables instead of using a variable for next sample program. each item. For example, if we need to enter one hundred names, it is difficult to declare 100 different names. Besides, if we want to process those data F. Nested Loops – you might need to start a that involves decision making, we might have to loop even if you’re already working through use hundreds of if...then statements, this is a waste another loop. This is known as nesting, and of time and efforts. So, instead of declaring one it’s similar in theory to the nesting hundred different variables, we need to declare demonstrated when you looked at If only one array. We differentiate each item in the statements. array by using subscript, the index value of each item, for example, name(1), name(2), name(3).......etc. , makes declaring variables more G. Infinite Loops - When building loops, you can streamline. create something called an infinite loop. This is a loop that, once started, never finishes. Dimensions of an Array An array can be one-dimensional or multidimensional. A one-dimensional array is like a Week 5: Timers and Random Function list of items or a table that consists of one row of items or one column of items. Timers Timer is a visual studio control that allows the A two-dimensional array is a table of items programmer to execute an instruction at a that make up of rows and columns. The format for a determined time without user intervention. one-dimensional array is ArrayName(x), the format for a two dimensional array is ArrayName(x,y) and a Random Function three-dimensional array is ArrayName(x,y,z). To generate a random numerical value, visual Normally it is sufficient to use a one-dimensional studio has an Rnd function to generate a pseudo- and two-dimensional array, you only need to use random value. Pseudo-random means not actually higher dimensional arrays if you need to deal with random as computers are not capable of more complex problems. generating random values. Instead it is derived from equations using values that changes every time such as your computer’s system time. Rnd function works by generating a value above 0 but below 1. To make this useful, we can use the number and multiply it to the range of random value we want to generate. To further understand the Rnd function, we will use it on a simple program that generates a random whole number value with a range defined by the user from minimum to maximum. In this program, we will need four textboxes that will display the random generated value (Rnd), Minimum (Min) to maximum (Max) value range, Declaring Arrays and the output or the generated random value We will use Dim statement to declare an (Output) with respect to the range defined. array just as the way we declare a single variable. The Public statement declares an array that can be The generated value from Rnd() function is stored in used throughout an application while the Dim C_RND. This is necessary as Rnd() function is used statement declares an array that could be used twice – in Textbox_Rnd display and the equation for only in a local procedure. Vout. The general syntax to declare a one dimensional array is as follow: Week 6: Working with Data Structures: Arrays and Dim arrayName(10) as dataType Subscript ‘(10) is the Subscript Array A subscript represents the position of the element An array is a variable with a single name that within the array. In the declaration above, the represents many different items. When we work with range of the array is up to 10. When you declare an a single item, we only need to use one variable. array, you need to be aware of the number of However, if we have a list of items which are of elements created by the Dim keyword. In the Dim similar type to deal with, we need to declare an arrayName(subscript) statement, subscript actually is a constant that defines the maximum number of elements allowed. More importantly, subs start with 0 instead of 1. Therefore, the Dim arrayName(10) statement creates 11 elements numbered 0 to 10. One Dimension Array This is a program that browses through a 10 entry String Array and update its content if the user wants to. This uses three buttons that will browse through the Array entries [Prev], [Next]. And a button that will change the value of the current selected array through the textbox, and also update the ListBox of the new contents of the 10 entry Array. Sorting Array This only works on one dimension arrays. You may sort an array by its contents alphabetically. You may use this instruction before displaying arrays in a listbox, or just sorting it to make it organized. Array.Sort(NameEmployee)...Where NameEmployee is the array name, no need to include subscript. Multi-Dimensional Array This program is identical in purpose as the previous sample program. The difference is that we use two arrays, one is a two-dimensional string array for first name and last name, and the other one is a single- dimension integer array that will store a grade-like data. Here, we are using two arrays. The possibility of mixing up the name and grade will not happen as long as the program uses a common index variable (listCtr for updating listbox, indexCtr for updating array data). We cannot join both as they have different data types, something to consider when using arrays on different data types. Good luck, fellow Dolphins! High scores cutie! - Central Student Council 2023 - 2024

Use Quizgecko on...
Browser
Browser