Shared Flashcard Set

Details

Programming chapters 1-3
n/a
77
Computer Networking
Undergraduate 4
10/07/2014

Additional Computer Networking Flashcards

 


 

Cards

Term
Keywords (Reserved Words)
Definition

* Words with special meaning that make up a programming language 

*Cannot be used for any other purpose

Term
Operators
Definition

*Special symbols that perform various operations on data 

 

 

example: +, -, *, /

Term
Variables
Definition

*Storage loation in memory represented by a name

*Name is chosen by the programmer

*In VB name must start with a letter or underscore 

Term
Syntax
Definition

*Set of rules that dictate how keywords, operators, variables and punctuation characters must be used 

*If a single syntax error appears in a program, it will not compile or execute 

Term
Statements
Definition

* Individual instructions in your program

*Made up of keywords, variales, operators and punctuation

*One statement is one line of source code 

 

ex: assigning a value to a variable

Term
Procedures
Definition

*Set of statements that perform a specific task

*A procedure has a name

*Can be executed from elsewhere in the program

Term
Comments (Remarks)
Definition

*Ignored by the compiler

*Helps programmer understand the purpose of programming statements 

*Beings with '

 

Term
User Interface
Definition

*Part the user interacts with

*All user interfaces were comand line

*Modern user interfaces are graphical (GUI)

Term
Objects
Definition

*Like a variable but in addition to containing data, it also has the ability to perform actions

*Objects properties - data that the object contains

*Object's methods - actions the object can perform 

*Name chosen by the programmer 

Term
Controls
Definition
*Usually appears in a programs graphical user interface
Term
Form Control
Definition
*The window that contains the other elements
Term
Textbox
Definition
*The small boxes that accept input
Term
Label Controls
Definition
*Areas that simply display text
Term
Button Controls
Definition
*Perform operations when clicked with the mouse
Term
Event Driven
Definition

*An action that takes place within a program

*All VB controls are capable of detecing various events, such as: 

Clicking a button control

or

Changing the text in a text box

Term
Event Handler
Definition
*For a control to respond to a specific event, you must write a special type of procedure
Term
Control Properties
Definition

*Each property has a value

*Some properties deal with the control's appearance 

Term
Name Property
Definition

*Establishes a means for the program to refer to that control

 

Term
Naming Conventions
Definition

*First three characters indicate the type of control

 

ex: lbl,txt,btn

Term
Programming Process
Definition

1. Clearly define what the program is to do

2. Visualize the application running on the cpu and design user interface

3. Determine the controls needed

4. Define the values of each controls relevant properties 

5. Determine the eents of each control that you need to handle

6. Create a flowchart or pseudocode verison of code

7. Check the flowchart or pesudocode for errors

8. Start VB and create forms and ontrols 

9. Use the flowchart to write code

10. Compile the program

11. Run the program

Term
Compile-time Error
Definition

*Problem with syntax of the source code

 

Term
Event Button
Definition
Lightning Bolt in the properties window
Term
Code Template
Definition

*the first line of the event handler

*We then add code to execute what we want

Term
Dot Operator
Definition

*Change a property at run-time

*[Control Name].[Property Name]=[value]

TextBox1.Text = "Hello World"
 

Term
Assignment Statement
Definition

*Assigns the value of the item on the right to the item that appears on the left side.

*The item receiving the value must be on the left!

Term
Intellisense
Definition
Auotmatic code completion
Term
Calling a method with code
Definition

*ObjectName.MethodName()

 

example: TextBox1.Clear()

or

Me.Close() 

 

Me is a keyword that refers to the current form. 

Term
Intellisense
Definition

*Property is a wrench icon

*Methods are cube icons

Term
Displaying a Message Box
Definition

MessageBox.Show("Hello User!") 

 

"Hello User!" is a string literal

 

OR 

 

MessageBox.Show(TextBox1.Text)

Term
F1
Definition

F1 is context sensitive: it opens the documentation for the item selected, or the item that the cursor is on. 

 

ctrl-f1 for general help 

Term
MSDN Documentation
Definition

Microsoft Developer Network

*Left hand pane is a directory. You can browse through the documentation.

* You can also search documentation using the search box (upper right corner)

Term
Debugging
Definition

*Compile-Time Error = problem with the syntax of the source code

*Run-Time error = problem that causes the program to fail while running

Term
Compile-Time Error
Definition

Prevents the program from compiling

 

ex: Me.Clost()

'Clost' is not a member of 'WindowsApplication1.Form1'

*You can double click the error message to go to the line of code

*Jagged underline in the code window

Term
Variable
Definition

*A storage location in coputer memory that holds data while a program is running 

*Called a variable because the data it holds can change 

Term
Variable Declaration
Definition

*A statement that creates a variable in memory 

* Indicates:It's name, and the type of data it will hold 

Term
Declaring a Variable
Definition

Syntax for declaring a variable

*Dim VariableName As dataType

Ex: Dim intLength As Integer 

Term
Dim Statement
Definition

*Dim keywords says we are declaring a variable.

*intLength is the variables name

*As integer indicates the variable will hold integer numbers 

Term
Naming Conventions
Definition

*Guideline to help improve readability but are not required syntax. 

*A variable name should describe its use 

*Data type prefix is lower case

*Subsequent word should be capitalized 

Term

Assignment statement 

Assign value 112 to variable intLength

Definition
intLength = 112
Term
Assign the string literal "Good Morning" the the variable strGreeting
Definition

strGreeting = "Good Morning"  

 

 

An assignment only changes the left operand

Term
Assign the contents of the text box txtName to the variable strGreeting
Definition
strGreeting = txtName.Text
Term
Assign the string literal "Good Morning" followed by the contents of the text box txtName to the variable strGretting
Definition

strGreeting = "Good Morning " & txtName.Text 

 

 

 

 

& is the string concatenation operator 

Term
Integer Types
Definition

Values that will always be a whole number 

 

*Byte - byt - unsigned integer from 0 to 255

*Short- shrt- signed integer from -32,768 to 32,767

*Integer- int- Signed from -2,147,483,648 to 2,147,483,647

*Long -lng - signed from -9,222,372,036,854,775,808 to 9,223,372,036,854,775,807

Term
Floating-Point Types
Definition

*Values that may have fractional parts

 

*Single-sng- 10 to the 38 plus or minus 7 decimals

*Double-dbl 10 to the 308 plus or minus 15 decimals

*Decimal -dec-10 to the 29 plus or minus 29 decimals

Term
Other data types
Definition

*Boolean-bln- either true or false

*Char- chr- holds a single character 

*String-str-holds a sequence of up to 2 billion characters

*Date -dat-can hold date and time

Term
Variable Initalization
Definition

*We usually want to initalize variables, unless we'll be assigning a value prior to using the variable

 

ex: Dim intLength As Integer = 12

Term
Variable Scope
Definition

*The part of the program where a variable is visible 

*Variable name can only be used once within its scope

 

cant do:

Dim intValue As Integer

Dim intValue As Integer 

 

 

 

 

Term
Local variable
Definition

*Variable declared inside a procedure, only visible in the procedure in which it appears 

 

must list Dim intValue As Integer

intValue = 12 

 

Cant just put intValue = 12

Term
Class-level variable
Definition

*Variable declared inside a class but outside any procedure, visible throughtout all procedures of the class

 

can just do intValue = 25

 

difference between the two is this one has end class at the bottom 

Term
Constant
Definition

*A constat is similar to a variable except it must be given an inital value, and once it is declared, its value cannot be changed.

*declare with const instead of Dim

 

ex: Const VariableName As DataType = value

Const dblSALES_TAX_RATE As Double = 0.065

Term
Constants
Definition

*Simplify code maintenance 

*Make code easier to understand 

*After the 3 character prefix name should be in ALL upper case letters 

 

 

Term
Arithmetic Operator : Addition
Definition
dblTotal = dblPrice + dblTax
Term
Arithmetic Operator : Subtraction
Definition
dblNetPrice = dblPrice - dblDiscount
Term
Arithmetic Operator : Mutliplication
Definition
intArea = intLength * intWidth
Term
Arithmetic Operator : Division
Definition
dblAverage = intTotal / intItems
Term
Arithmetic Operator : Exponentiation
Definition
dblCube = dblSide ^ 3
Term
Combined Assignment Operators
Definition

*Sometimes we need to change the value in a variable with an operation, such as adding a number to it 

 

intQuantity += 1 

 

is like intQuantity +1

Term
Operator Precedence
Definition

*Operator precedence tells us the order in which operations are performed.

Highest to lowest 

1. Exponentiation 

2. Mutiplication and division

3. Addition and subtraction

Term
Type Conversion
Definition

*A value of one data type can be assigned to a variable of a different type. 

 

 

implicit and explicit

Term
Implicit Type Conversion
Definition

*A numeric type conversin will be either widening or narrowing

*Widening conversion suffers no loss of data 

ex: converting an integer to a double 

Dim dblVal as Double = 5

 

*Narrowing conversion may lose data

ex: converting a deciaml to an integer

Dim intNum As Integer = 12.2 becomes 12 

Dim intNum as Integer = 12.5 becomes 13

Term
Explicit Type Conversion
Definition

*Cint - converts expression into an integer

*CDbl- converts expression to a double

*CDate- converts expression to a date

*CDec - converts expression to a decimal

*CStr- converts expression to a string

Term
Explicit Type Conversion Examples
Definition

*Rounding with CInt

intCount  CInt(12.4) value is 12

 

*CStr converts a numberic value to string 

Dim strText As String = CStr(3.14) value is 3.14

 

*CDec converts string to decimal

Dim decPay As Decimal = CDec ("1,500") converts to 1500.0

 

*CDate 

Dim datHired as Date = CDate("9/14/2014")

Term
Invalid Conversions
Definition

*xyz cant be converted to a number

*theres no 35 day in a month

*These cause a runtime error 

Term
Formatting Numbers and Dates with ToString
Definition

*Converts the contents of the variable to a string.

*Call by using the dot operator

ex: VariableName.ToString()

Dim number As Integer = 123

lblNumber.Text = number.ToString()

 

^ This converts the integer 123 to the string "123" and assigns it to the text property of the lblNumber control

Term
Formatting Numbers and Dates with ToString
Definition

Dim decGrossPay As Decimal

Dim strResult As String 

decGrossPay = 1228.54

strResult = decGrossPay.ToString("c") 

 

changes the format string into currency 

Term
Exception Handling
Definition

Exception is any error condition or unexpected behavior that is encountered by an excuting program 

 

ex: Dim dblSalary As Double = CDbl ("xyz") 

 

*Allows a program to fail gracefully and recover if possible

*A runtime error results when an exception is unhandled

Term
Exception Handling
Definition

Try Catch statement

*Try block contains program statements that might throw an exception

*The catch block contains statements to execute if an exception is thrown 

 

Try

'Try block statements.....

Catch

'Catch block statements 

End try

 

 

Term
Logic Errors (bugs)
Definition
If your program compiles and runs, but does not work correctly or produces incorrect results
Term
Debugging Tools
Definition

*Breakpoints

*Watch windows 

*Single-stepping through the program 

Term
Breakpoint
Definition

*Click the mouse in the left margin of the code window

*A red dot appears next to the line in the left margin and the line becomes highlighted. This indicates that a breakpoint has been set on this line

*When you run the program, execution will pause on this line

Term
Watch Window
Definition

*While your program is paused on a breakpoint you may inspect the contents of variables and object properties

 

Term
Single-Stepping
Definition

*Executing code one line at a time. Press F8 to execute the current line and then pause at the next line. The execution point is indicated by yellow highlighting and small arrows. 

*Press F5 to contine normal execution

Term
Focus
Definition

*Only one control can have the focus

* txtUserName.Focus()

*It has focus by it's blinking or thin dotted line

Term
Tab Order
Definition

*Moves focus from one control to another by pressing tab key.

*default: tabs are in the same order as you created them

* go to view menu, click tab order, click the control sequentially to establish the tab order you want, when finished click tab order on the view menu again to leave. 

*Also can change in properties window TabIndex property 

Term
Group Box Control
Definition

*Encloses boxes with a bigger box. 

*Boxes within are related in some way

Term
Access Keys
Definition

*Alt + x = Exit

* The access key will appear underline on the control 

Supporting users have an ad free experience!