Вы находитесь на странице: 1из 3

Introduction to Visual Basic (ITSE 1331) Exam 1 Gaddis/Irvine

Hardware Hardware a computer's physical components. 1. The central processing unit (CPU) 2. Main memory 3. Secondary storage devices 4. Input devices 5. Output devices Software 1. Creating the GUI elements that make up the application's user interface 2. Setting the properties of the GUI elements 3. Writing programming language statements that respond to events and perform other operations. Developing an Application 1. Make a list of methods needed for each control 2. Make a list of the controls needed 3. Create a flowchart or pseudocode version of each method. Programming an Application

Software programs that run on a computer. Application software programs that make the computer useful
to the user and perform general user needs. Operating systema set of programs that manages the computer's hardware devices and controls their processes. Algorithm Algorithma set of well-defined steps for performing a task and describes a problem solution. CPUonly processes instructions written in machine language Object Oriented Programming

Keywordhas a special purpose and cannot be used as a variable


or other identifier.

understand the purpose of program statements (the code). Identifiera programmer defined name that is not part of the Visual Basic programming language. Any control whose name appears in a programming statement should have a descriptive, programmer-defined name. Object a reusable self-contained unit. Has properties, methods, Flowcharts and pseudo code used to outline the solution to a problem. Example: and events. Saving a Visual Basic.NET project 1. Make a list of methods needed for each control. 1. Click File on the menu bar, and then click Save All on the File 2. Make a list of the controls needed. menu. 3. Create a flowchart or Pseudocode version of each method. 2. Press Ctrl+Shift+S on the keyboard Testing a program with sample data to insure that the program 3. Click the Save All button on the standard toolbar. handles the calculations correctly. Ending a Visual Basic.NET application DebuggingFinding and fixing programming errors. 1. Click the close button on the applications window. Compile time errors (compilation errors)errors such as 2. Click Debug on the menu bar, and then click Stop Debugging misspelled key words or incorrect use of operators. on the Debug menu. Running an application 3. Double click the Stop Debugging Icon on the extended Tool 1. Click the start button on the toolbar. Bar while the program is running. GUI (Graphical User Interface) applications are more complex 2. Press the F5 key. 3. Click Debug on the menu bar, and then click Start on the for programmers to write. Debug menu. Event procedurea type of sub procedure also known as event Visual Basic Environment handlers. Display the Designer window click View on the menu bar, and 1. A correct name for an event procedure that will be then on the view menu click Designer. executed when the user clicks on a Button control named Auto hide feature will cause the window to stay minimized as a btnDisplayList could be btnDisplayList_Click. (Remember, tab along one of the edges of the screen until the mouse cursor is control names may not contain spaces.) over the tab. 2. A correct assignment statement for a label control named lblTitle that would align the control's text with the middle and Toolbar can be used as a shortcut for executing commands found in the menu. center of the control's bounding box would be 1. Used to select controls and place on an application form. lblTitle.TextAlign=ContentAlignment.MiddleCenter. Event examples Display a tooltip hold the mouse cursor over a button on the 1. Click a control toolbar or toolbox for a few seconds. 2. Change focus of a control TextBox controltypically used to input data. 3. Change contents of a textbox Toolbox purpose is to select controls and place an application Intellisenseprovides some automatic code completion while form. developing a program. Run time modethe mode in which you run and test an ControlGUI elements such as CheckBox, ComboBox, Button, application. Can interact with the program as it executes. Label, TextBox, Form, etc. Writing a Visual Basic Project For example: txtName.Text, the property is Text Label controla box that displays text that cannot be changed or Visual Basic ProjectVisual studio creates a folder to hold the solution and project. When a project is created, it must belong to entered by the user. a solution. Control Visible propertywill be displayed during design time Assignment operator uses the equal sign. The assignment when set to false. statement copies the value on its right side into the item on its Creating VB applications you change control properties

Comments (Remarks) helps the human reader of a program

left. The value of a control's property may be changed while the application is running by using an assignment statement. Multiplication operatoruses the asterisk. Examples: dblPerimeter = 2 * dblLength + 2 * dblWidth lblTitle.Text = "Visual Basic" File extensionVB.NET projects saved with the .proj file extension. Lock all of the controls on a form during design timeright-click on an empty spot on the form, and select the Lock Controls option from the pop up menu. Code to close a formMe.Close() Context-sensitive helpa help screen that is displayed when the F1 key is pressed (for the item that is currently selected) Contents of the Project Folder (of a project named Directions)

control's size on a form. Deleting a control from a form 1. Select the control, then use the cut option on the menu bar 2. Select the control, then hit the delete key. 3. Select the control, then select delete from the edit menu. Undo button on the standard toolbarused to restore a control if it is accidentally deleted. SizeMode propertya PictureBox property that determines how the control will position and scale its graphic image. FormBorderStyle propertya property that configures a form's border; allows or prevents resizing, minimizing, or maximizing a window. Valid values include: 1. Fixed3D 2. Sizeable 3. FixedSingle bin foldercontains the application's executable code Code Window My Project foldercontains various application settings Display the Code window files 1. Click view code button on the Solution explorer window. obj folderholds temporary files that are created during 2. Click View on the menu bar, and then click the Code the compilation process. command. 3. Press the F7 key. Directions.vbprojThis is the project file. The project file contains information needed by Visual Studio a out the Code regiona section of code that may be hidden from view, or Directions project. In Windows, you can double-click the collapsed. project file and the project will be loaded into Visual Controls Studio. Textbox control used to gather input the user has typed on the Directions.vbproj.userThis file contains information keyboard. You clear a textbox with code by assigning a blank to about Visual Studio's IDE settings. the text property. Form1.Designer.vbThis file contains the Visual Basic Textbox and Button Controlscan have the focus. code to generate the Form1 form and all of the controls on Tab Orderthe order in which controls receive the focus. it. Form1.resxThis file contains information about various Tab Order Selection Modelets you view the TabIndex of each of the controls on the form. resources needed by Form1 form. View Tab Orderall controls on a form will receive the focus by Form1.vbThis file contains Visual Basic code that you clicking View on the menu bar and then Tab Order. write. String Concatenation Properties Window Properties Windowlists the properties of the controls. You can Ampersand symbol (&) used to perform string concatenation. use the object box on the Properties window to select any object Line continuation in the project. Line continuationto break up a long line of code, so that it fits in the code window type a space, followed by an underscore and 1. A few of the properties, including the Name property are then hit the enter key. enclosed in parenthesis to make them appear at the top of the Variables and Named Constants alphabetical list. A programming statement must reer to a control by its Name property. Variablea memory location that holds information while the View the properties window: program executes. 1. Pressing the F4 key Declaration Statementgive variables and constants names, and 2. By clicking on the properties icon above the Solutions explorer specify the type of data they will hold. window. Naming Variable Rules 3. Go to the view menu and the clicking properties. 1. May contain underscores Sizing handlesappear when you select an existing control on a 2. May contain letters form during design time. 3. May contain digits (not the first position) Label controlused to create labels to display text on a form Dim Statement to declare a variable use a Dim statement: which cannot be modified by the user. If a label control is not Dim variableName As DataType wide enough for the text that is written into that control, then the For example: Dim strName As String extra text is wrapped onto the next line or lines. Example: To Dim intLength As Integer = 26 display the words "Visual Basic" in a label named lblTitle write Dim index As Integer lblTitle.Text = "Visual Basic" The Dim statement for a class-level variable must be outside any 1. Autosize property of a label control allows a label to change procedure, and between the Public Class statement and the End size to fit the amount of text in its text property. Class statement. The following actions can be performed with variables:

Bounding boxa transparent rectangular area that defines a

1. Copy and store values entered by the user, so they may be manipulated. 2. Perform arithmetic on values. 3. Remember information for later use in the program. Named constantlike a variable whose content is read-only and cannot be changed by a programming statement while the program is running. Advantages are: 1. They make the program more self documenting since they can describe the meaning of the constant value. 2. It is easier to make widespread changes to a named constant throughout a program. 3. The value of the constant cannot be changed within the program. 4. When you declare a constant, you must assign it an initial value. Variables declared with a button's click-event are local variables. class-level variable: 1. can be declared anywhere between Public Class and End Class (inside a class) 2. visible to all statements inside the class 3. not local to any procedure 4. declared outside a procedure 5. accessible to all procedures in a class Conversions

1. Exponentiation (the ^ operator) 2. Multiplication and division (the * and / operators) 3. Integer division (the \ operator) 4. Modulus (the MOD operator) 5. Addition and subtraction (the + and operators) Assignment operator (=)the expression on the right of the = operator is evaluated and assigned to the variable on the left. For example lblDisplay.Text = txtInput.Text Combined Assignment Operators Example Equivalent to += x += 2 x=x+2 = x=5 x=x5 *= x *= 10 x = x * 10 /= x /= y x=x/y \= x \= y x=x\y &= strName &= lastName strName & lastName Events and Methods

Load Event Procedurea procedure that is executed each time a

Implicit Type Conversionwhen you assign a value of one data

type to a variable of another data type, Visual Basic attempts to convert the value being assigned to the data type of the variable. Option strictin Visual Basic, a configuration option that determines whether certain implicit conversions are legal. ToString methodeach of the Visual Basic data types has a ToString method, which returns a string representation of the variable calling the method. CIntConverts a numeric or string expression to an Integer. If the expression converts to a value outside the range of an Integer, or is not a numeric value, a runtime error is generated. Rounds to nearest integer. CSngConverts a numeric or string expression to a Single. If the expression converts to a value outside the range of a Single, or is not a numeric value, a runtime error is generated. The input expression may contain commas, as in "1,234" Real number assigned to an integer variablenarrowing conversion when allowed. The value is either rounded downward or upward. For example: FormatNumber(12.283, 1) returns 12.3 Type Conversion Errora runtime error that is generated when a nonnumeric value that cannot be automatically converted to a numeric value is assigned to a numeric variable or property. : Working with Numbers + Addition Subtraction * Multiplication / Floating-point division \ Integer division MOD Modulus (remainder from integer division) ^ Exponentiation Example: answer = 24 Mod 9 (answer is 6) The precedence of the arithmetic operators, from the highest to lowest:

form loads into memory. If you want to execute some code at this point, you can write the code in the form's Load event handler. Event handlerthe code that is executed when an event occurs, such as a button is clicked, a form loads, a mouse over, etc. MessageBox.Show methoddisplays a Message Box. If you want to display multiple lines of information in a message box, use the constant ControlChars.CrLf (CrLf stands for carriage return line feed). Notice that both the C and L in CrLf are uppercase. Example for one line message: MessageBox.Show("Hello World") General format for the method call that displays a message box: Messagebox.show(Message, Caption, Buttons, Icon, DefaultButton) Data Types

Date Data Typedefaults to 12:00:00 AM, January 1 of the year 1 Boolean Data Typedefaults to False String Data Typesequence of characters surrounded by double
quotes

Integer Data Typeoptional leading sign, sequence of decimal

digits, followed by optional letter I Decimal Data TypeOptional leading sign, sequence of decimal digits, optional decimal point and trailing digits, followed by the letter D or @

Вам также может понравиться