Vous êtes sur la page 1sur 8

SCANLAN MIDTERM for MIS 15!

What is an object?
An object is an item contains data and has the ability to perform operations.
What is a method?
A method is the operation that an object can perform
What is a class?
A program structure that defines a data type.
Case structure
Select Case control structure is slightly different from the If.ElseIf control structure . The difference is that
the Select Case control structure basically only make decision on one expression or dimension (for example
the examination grade) while the If ElseIf statement control structure may evaluate only one expression,
each If.ElseIf statement may also compute entirely different dimensions. Select Case is preferred when
there exist multiple conditions because using IfThen..ElseIf statements will become too messy.
Nested IF-THEN-ELSE
We need to use nested If...Then... Else statements if a condition is depending on other conditions that have
to be fulfilled first. A nested If statements are enclosed within other If statements.
IF-THEN-ELSE LOGIC
Text property
Assignment operator "="
Assigns value to variables. Can be assigned from raw value to variable or pass values from variable to
variable byVal.
Changing properties in the code
.sln file
Organizes projects, project items and solution items into the solution
Comment
Me.Close()
Closes current application on button press it is assigned to
Prefixes on objects, constants and variables and constants

obj = objects CONST variables = int, dbl, txt, lbl, rbtn, chk, ...
Logic and syntax errors
StretchImage
FormatCurrency
Format currency changes the output of a double or an int to be shown as currency with $ out front and
rounded to 2 decimal places

Draw a line on a form


This example draws a line on a form. Typically, when you draw on a form, you handle the forms Paint event
and perform the drawing using the Graphics property of the PaintEventArgs,
.Clear()
Is an object method (actions the object performs) that clears a textbox of its contents.ex. txtInput.Clear()

Checkbox
The Check box is a very useful control in Visual Basic 2010. It allows the user to select one or more items by
checking the check box/check boxes concerned
.
RadioButton
The radio button is also a very useful control in Visual Basic 2010. However, it operates differently from the
check boxes. While the checkboxes work independently and allow the user to select one or more items ,
radio buttons are mutually exclusive, which means the user can only choose one item only out of a number
of choices.

Visible property
Type: System.Boolean
true if the control and all its child controls are displayed; otherwise, false. The default is true.

WithEndWith
By using With...End With, you can perform a series of statements on a specified object without specifying
the name of the object multiple times. Within a With statement block, you can specify a member of the object
starting with a period, as if the With statement object preceded it.

For example, to change multiple properties on a single object, place the property assignment statements
inside the With...End With block, referring to the object only once instead of once for each property
assignment.
If your code accesses the same object in multiple statements, you gain the following benefits by using the
With statement:

You don't need to evaluate a complex expression multiple times or assign the result to a temporary
variable to refer to its members multiple times.

You make your code more readable by eliminating repetitive qualifying expressions.

Line continuation character


To break a single statement into multiple lines Use the line-continuation character, which is an underscore
(_), at the point at which you want the line to break. The underscore must be immediately preceded by a
space and immediately followed by a line terminator (carriage return).

Numeric data types


Numeric data types are types of data that consist of numbers, which you can compute
them mathematically with various standard operators such as add, minus, multiply, divide
and so on.

What is a variable?
When you declare a variable or constant, you are telling the program to reserve a physical location for this
variable or constant in memory and to format that location so that it can hold a certain type of data, such as
decimal, string, integer, etc.
You are also giving the location a name (an identifier) to be used to access its physical location.

Dr. Scanlan's rules for forming variable and constant names.


User-defined names must be as meaningful as possible and as short as possible or as long as necessary.
Concentrate on short and meaningful.
Naming Rules: Variable and Constants(all upper case, lngSPEED_OF_LIGHT)
Letters, digits, and underscore, only.
Begin with a letter.

No spaces or periods
No reserved words (keywords)
Reserved words can be imbedded in the variable or constant name.
Example intDimLightValue is ok even though it has a reserved
word in it; that is, "Dim"
Maximum length: 16,383 characters
Variable and constant names are collectively called IDENTIFIERS.
When we use a name for a physical location in memory, we call this name an IDENTIFIER.

Module-level declarations
Variables declared at this level can be used in any sub procedure in Form1.

Local variables
A local variable is one that is declared within a procedure. a local variable in a procedure ceases to exist as
soon as the procedure stops.

Scope
Scope refers to the parts of the program that are allowed to use the variable.
A good programmer tries to restrict variable access to only the part/s of the program that need the access.

Lifetime of variables
Local variables are initialized to zero each time their sub procedure in which they were declared is called.
Thus, numeric variables get initialized to zero and string variables get set to null.
Module-level variables are initialized when the program first starts, and keep their last assigned value UNTIL
the program is STOPPED.

What is casting?

Casting is the process of converting one data type to another, for example, from an Integer
type to a String type.

How does try/catch work?


VB.NET has a inbuilt class that deals with errors. The Class is called Exception. When an exception error is
found, an Exception object is created. The coding structure VB.NET uses to deal with such Exceptions is
called the Try Catch structure. The Try word means "Try to execute this code". The Catch word means
"Catch any errors here". The ex is a variable, and the type of variable it is is an Exception object
Casting errors
Arithmetic operator precedents
Any operation inside parentheses
(Multiple operations within parentheses use rules of precedence)
2. Exponentiation
(Multiple ^ operations are performed left to right)
3. Multiplication and division
(Multiple * or / operations are performed left to right)
4. Integer division
(Multiple \ operations are performed left to right)
5. Modulus
(Multiple Mod operations are performed left to right)
6. Addition and subtraction
(Multiple * or / operations are performed left to right)
+=, -= , etc.
Accumulating
Option Explicit On/Off
Forces explicit declaration of all variables in a file, or allows implicit declarations of variables. When Option
Explicit On or Option Explicit appears in a file, you must explicitly declare all variables by using the Dim or
ReDim statements. If you try to use an undeclared variable name, an error occurs at compile time. The
Option Explicit Off statement allows implicit declaration of variables.
If used, the Option Explicit statement must appear in a file before any other source code statements.

Option Strict On/Off


Option strict determines whether certain implicit data types conversions are legal. Option strict on, only
widening conversions are permitted. (such as integer to single & left-to-right). Decimal can be converted to
Single, Integer to double etc. Option Strict Off allows all types of numeric conversions to take place with
possible loss of data.
ASCII sequence
Unicode
A set of numeric codes that represent all the letters of the alphabet (lower/upper case 0-9, special chars and
punctuation).
Character Casing
AND/OR in conditions
Logical operators can combine multiple boolean expressions to for a single expression. And Combines to
expressions into one. Both expressions must be true for the expression to be true. Or combines two
expressions into one but only one (or both) has to be true for the expression to be true.
Debugging
Debugging function key
f11 or f8

Arguments and parameters


A parameter represents a value that the procedure expects you to pass when you call it. The procedure's
declaration defines its parameters.
When you define a Function or Sub procedure, you specify a parameter list in parentheses immediately
following the procedure name. For each parameter, you specify a name, a data type, and a passing
mechanism (ByVal (Visual Basic) or ByRef (Visual Basic)). You can also indicate that a parameter is
optional. This means that the calling code does not have to pass a value for it.The name of each parameter
serves as a local variable in the procedure. You use the parameter name the same way you use any other
variable.
Function procedures and sub procedures
#Region/End Region
Use the #Region directive to specify a block of code to expand or collapse when using the outlining feature
of the Visual Studio Code Editor. #Regionstatements support block semantics (such as #If...#End If),
meaning that the start and end must be in the same code block. You can place, or nest, regions within other
regions to group similar regions together

Static variables
A static variable continues to exist and retains its most recent value. The next time your code calls the
procedure, the variable is not reinitialized, and it still holds the latest value that you assigned to it. A static
variable continues to exist for the lifetime of the class or module that it is defined in.

How must argument and parameters match?


A parameter represents a value that the procedure expects you to pass when you call it. The procedure's
declaration defines its parameters.
When you define a Function or Sub procedure, you specify a parameter list in parentheses immediately
following the procedure name. For each parameter, you specify a name, a data type, and a passing
mechanism (ByVal (Visual Basic) or ByRef (Visual Basic)). You can also indicate that a parameter is
optional. This means that the calling code does not have to pass a value for it.
The name of each parameter serves as a local variable in the procedure. You use the parameter name the
same way you use any other variable
An argument represents the value that you pass to a procedure parameter when you call the procedure.
The calling code supplies the arguments when it calls the procedure.
When you call a Function or Sub procedure, you include an argument list in parentheses immediately
following the procedure name. Each argument corresponds to the parameter in the same position in the list.
In contrast to parameter definition, arguments do not have names. Each argument is an expression, which
can contain zero or more variables, constants, and literals. The datatype of the evaluated expression should
typically match the data type defined for the corresponding parameter, and in any case it must be convertible
to the parameter type.
Syntax for sub-procedures and functions.
A function is an assignment that a piece of code can take care for the functionality of a database. The main
difference between a sub procedure and a function procedure is that a function can return a value.A function
is created like a sub procedure with a few more rules. The creation of function starts with the Function
keyword and closes with End Function.

A sub procedure is a section of code that carries an assignment but doesn't give back a result. To create a
sub procedure, start the section of code with the Sub keyword followed by a name for the sub procedure. To
differentiate the name of the sub procedure with any other regular name, it must be followed by an opening
and closing parentheses. The section of the sub procedure code closes with End Sub

Function with and without Return


The value a Function procedure sends back to the calling code is called its return value. The procedure
returns this value in one of two ways:

It uses the Return statement to specify the return value, and returns control immediately to the calling
program.

It assigns a value to its own function name in one or more statements of the procedure. Control does not
return to the calling program until an Exit Function or End Function statement is executed. The following
example illustrates this.
The advantage of assigning the return value to the function name is that control does not return from the
procedure until it encounters an Exit Function or End Function statement. This allows you to assign a
preliminary value and adjust it later if necessary.

ByRef vs ByVal
In Visual Basic, you can pass an argument to a procedure by value or by reference. This is known as the
passing mechanism, and it determines whether the procedure can modify the programming element
underlying the argument in the calling code. The procedure declaration determines the passing mechanism
for each parameter by specifying the ByVal (Visual Basic) or ByRef (Visual Basic) keyword.

Vous aimerez peut-être aussi