Furman University



Instructor Reference Card VBACHAPTER 1Extending Microsoft OfficeConcepts–At a Glance Summary KEY CONCEPTS (blue)–most important concepts/skills in this chapterKEY TERMS (black)–most important key terms in this chapterTIPS (red)–useful shortcuts and information for more productive use of VBASTICKY POINTS (green)–areas that might cause difficulty for studentsIntroduction to VBAVisual Basic for Applications (VBA)–A programming language to customize and enhance the functionality of Office applicationsProject–A collection of modules, macros, and objects in a Microsoft Office fileModule–A container to organize programming codeProperty–An attribute of a currently selected object; it is similar to the Property Sheet used to set properties for Access database objects.TIP–To display the Properties window in the VB Editor, select View, and then select Properties Window.Code window–A window within the VB Editor for writing and editing VBA statementsTIP–To display the VB Editor in Excel, click the Developer tab, and then select Visual Basic.STICKY POINT–To display the Developer tab, click the File tab, click Options, click Customize Ribbon, click the Developer tab check box in the Main Tabs list on the right side, and then click OK.TIP–To display the VB Editor in Access, click the Database Tools tab, and then select Visual Basic.TIP–You can display the VB Editor in Office applications by pressing Alt+F11.Procedure–A named sequence of programming statements that performs a series of actions. Procedures are classified as either sub procedures or function procedures, which often require arguments.TIP–You can run a procedure from either the Macros dialog box or from within the VB Editor.Design time–The mode for designing, writing, and editing programming codeRun time–The mode for executing a program; during run time, you interact with the application as a user.STICKY POINT–If you have created macros or written VBA procedures for an Excel workbook, save it in the Macro-Enabled Workbook file format (.xlsm) because you cannot store VBA code in regular Excel workbooks (.xlsx).Keyword–A word or symbol used for a specific purpose in a programming language. Keywords are color-coded blue in the Code window.TIP–When the insertion point is within a keyword, press F1 to obtain help about that particular keyword.Syntax error–Occurs when the code contains a misspelled or misused keyword, incorrect punctuation, or undefined elements. Syntax errors are color-coded red in the Visual Basic Editor.TIP–To have VBA automatically check and correct syntax, select Tools, select Options, and then select the Auto Syntax Check ment–Text that explains a section of programming code. Comments begin with an apostrophe or the keyword Rem followed by a space and are color-coded green.Standard module–Stores procedures that can be used by any object in the application.Class module–Enables the creation of custom objects along with properties and methods.Object-oriented programming language–Uses methods to manipulate objects.Method–An action that acts on an object.Event–An action at run time that triggers the execution of code. The most frequently used event is the click of a button.Sub procedure–Performs an action but does not return a specific value. Begins with Sub and ends with End Sub.Function procedure–Performs an action and returns a value. Begins with Function and ends with End Function.Property procedure–Creates or manipulates a custom property. Begins with Property Let, Property Get, or Property Set and ends with End Property.Public procedure–Available to any object in the application. It is the default.Private procedure–Available only to a specific object or module.Message box–A dialog box that displays a message or information and contains buttons for the user to click to perform alternative actions. Message boxes can also display icons.STICKY POINT–You cannot combine two or more button sets or two or more icon sets in the same code statement.MsgBox statement–Displays a message box onscreen with optional buttons, icons, and title bar text.MsgBox function–Displays a message box onscreen and returns an integer to indicate which button the user clicked.STICKY POINT–Remember to assign the returned integer to a variable.Argument–A value that provides necessary information to a procedure or a function.Line-continuation character–A space followed by an underscore that programmers manually insert to display one statement on two or more physical lines in the VB Editor.Immediate window–A small window to enter and run small segments of codeTIP–To display the Immediate window, select View, and then select Immediate Window.Variables, Constants, Input, and OutputVariable–A programmer-defined name that stores values that can change while the application is running. Users can change a variable's value during run time by using the Dim statement.TIP–To use a value stored in a variable in all procedures in a project, use the Public statement instead of Dim.STICKY POINT–Variables are stored in computer memory and are lost when the program ends.Constant–Stores values that remain constant while the application is running. Users cannot change a constant's value during run time. VBA supports three types of constants: intrinsic constant, symbolic or user-defined constant, and conditional compiler constant. Use the keyword Const. Constants are private by default.Data type–Specifies which type of data can be stored in the variable or constant and how the data is stored in the computer's memory. Data types include: Byte, Boolean, Integer, Long, Currency, Decimal, Single, Double, Date, String, Object, Variant (default).TIP–When naming variables and constants in VBA, it is recommended to begin the name with the first three characters in lowercase indicating the data type and the remainder beginning with an uppercase letter specifying the purpose.Integral data type–Stores only whole numbers.Declaration–A statement that creates a variable or constant and specifies its data type and name.STICKY POINT–Make sure the value you assign matches the data type you specify.Scope–Specifies which statements can access a variable or constant. You can specify procedure scope or module scope.Input box–A dialog box that prompts the user to enter data. Input boxes do not have icons.STICKY POINT–A programmer should include instructions for how to enter data as part of the prompt for the input box so the text string converts correctly to a numeric value.InputBox function–Displays a prompt dialog box to the user to enter a value.Concatenate–The process of joining two or more text strings. Use the ampersand character (&) or plus sign (+).Val function–Converts text into a numeric valueOperator–One or more characters that performs a calculation. VBA supports six types of operators: arithmetic, assignment, comparison, concatenation, logical, and miscellaneous.Order of precedence–The order in which arithmetic operations are performed—left to right in the following order: parentheses, exponentiation, multiplication or division, and addition or subtraction. You can use parenthesis to override the order of precedence.Format function–Formats the results of calculations.Decision StructuresProgramming structure–The sequence in which the program statements execute at run time. You can use a sequence structure, a decision structure, or a repetition structure.Sequence structure–Executes the statements in the order they are listed in the procedure.Decision structure–A block of code that uses relational operators to make comparisons and then executes alternative statements based on the outcome. Use If…Then, If…Then…Else, or Select Case.Condition–An expression that determines if a situation is true.Relational operator–A symbol or word that determines the relationship between two statements.Logical test–Evaluates the truth of the stated relationship.If…Then statement–Performs a logical test and executes one or more statements if the test is True.If…Then…Else statement–Performs a logical test and executes different statements based on whether the test is True or False.Select Case statement–Compares an expression and then executes the code for the matching case. When the structure tests a single value, the Case Is statement is used. When the structure tests a range of values, the word Case is followed by the range of values.Data validation–The process of checking data entered to ensure it meets certain requirements.IsNumeric function–Checks a string and returns True if the string can evaluate to a value or False if the string cannot evaluate to a value.Logical operator–Uses Boolean logic to perform a logical test.And operator–A logical operator that requires that two or more conditions be met to evaluate to True.Or operator–A logical operator that requires that only one condition be met to evaluate to True.STICKY POINT–Text comparisons are case sensitive and must match the text string specified in the logical test.Repetition StructuresRepetition structure–Repeats the execution of a series of statements at run time. You can use For…Next or Do…Loop.For…Next statement–A repetition structure that repeats statements a specific number of times.Loop–The set of statements that repeats for a repetition structure.STICKY POINT–Test your loop to make sure it does not run infinitely.Iteration–One execution of a loop statement.Counter variable–Used to count the number of times a loop repeats.Step value–The amount the counter is incremented during each cycle of the loop.TIP–Specifying the step value is optional. Either a positive or negative number can be specified. If omitted, VBA uses a default value of 1.Do…Loop statement–A repetition structure that repeats designated statements as long as a condition is true or until a condition is satisfied. Uses the keywords While or Until.Pretest–Performs the logical test first and executes the code within the loop if the test is true.Posttest–Executes the code within the loop one time and then performs the logical test to determine if the loop iterates. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download