Sie sind auf Seite 1von 13

Exam Night Revision

Chapter One : Data Type :


- Data type sets the type the information that will be stored .
- Each data type has a certain space in the computer memory .
1- Numeric Data Type .
- To store numeric data only .
a. Integer Numeric Data : ( Byte - Short - Integer - Long ) .
b. Non-Integer Numeric Data : ( Single - Double - Decimal ) .
2- Character Data Type :
- To store text data ( characters - spaces and symbols - numbers not
used in the arithmetic operation ) .
a. Char :to store one character only .
b. String :to store a big set of characters or data .
3- Miscellaneous Data Types :
a. Boolean :to store logical data ( True / False ) .
b. Date :to store data in the form of Date .
c. Object :takes the form of an object .
- You can know the used data type by pointing by the mouse
pointer on the property in the assignment statement ,so a
comment appears displaying the data type .
Variables :
- " They are locations in the computer memory ( RAM ) that have
data type . Their values can change during the program runtime " .
Formula of declaring variables :
Dim Variable Name As Data Type

134

- Instructions for selecting names of variables and constants :


1- The variable name should start with a character or underscore
(_).
2- The name should not contain symbols and special signs as
( space, ? , . , comma ,... ).
3- The name can contain characters , numbers and underscore .
4- The name should not be from the reserved words in
VisualBasic.Net :
( AS - Single - Dim - .. )
5- The variable or constant name should identify its content .
- To select the suitable data type for the variable or
constant , we should consider the following :
1-Size of the stored data .
2- Type of the stored data and whether arithmetic or logical
operations can be performed on them .
Assignment :
- A statement of two sides with ( = ) between them and it enables to
store a value in a variable or property .
Formula of Assignment :
Variable Name or Property = Value
Conditions of Assignment :
1- The variable or property name in which the value will be stored
should be at the left of ( = ) .
2- The value that will be stored should be suitable to the variable or
property type .
3- The value that will be stored may be as :
( Expression - Property - Variable Value - Abstract Value )

135

Use of Variables :
a. Left Side :That the variable is the location where the value will
be stored .
b. Right Side :That the variable here is the value that will be stored
or part of it .
- ( Me ) : Of the used words in VisualBasic.Net and it indicates to
the current Form window .
- ( & ) : it is used in Visual Basic.Net to link the text values to make
one text value .
- ( VbCrlf ) : of used words in VisualBasic.Net and is used in the
code window to create a new line .
- ( Under Score ) ( _ ) : it is typed at the end of the code line to
complete the code line in the next line .
- ( Rem ) or (' ) : it is typed at the start of the line in the code
window to make the code as a comment so the compiler doesn't
execute it during the program runtime.
Constants :
- They are locations in the computer memory ( RAM ) that have
data type and their values cannot change during the program
runtime .
- The constant should take a value when declaring it .
Formula for declaring Constants :
- Const Constant Name As Data type = Value
Range of Variables and Constants :
- It means the allowed range for using a variable or constant .
- Visual Basic .Net do not allow using any variable or constant out
the range of declaration .

136

Errors :
1- Syntax Errors :
- They occur when typing words with typing errors in the code
window .
Example :
- Dem H As Integer.
2- Logical Errors :
- They are the errors which result in False results when using the
program as typing an equation or assignment incorrectly .
To avoid those errors we should :
a. Check the codes in Code Window well .
b. Check the validity of the program through inputs with predefined
outputs .
3- Runtime Errors :
- They are the errors which occur as a result of the user input
incorrect values during the program runtime .
( The programmer will not be responsible directly for this error )
How to avoid the ( Runtime Errors ) :
a. By using ( Try . Catch )
- It finds the runtime errors and enables the programmer to answer
the error with a clear message .
Form of ( Try . Catch ) statement :
Try
The codes that may have errors
Catch
The codes that should be executed in case of error .
End Try

137

B. Set the User Inputs :


- By setting the control tools on the Form window to enable the user
to select values in place of typing them by himself .
Priorities for performing the Arithmetic Operations :
1- The operations between the brackets from in to out .
2- Exponents .
3- Multiplication and Division from left to right .
4- Add and Subtraction from left to right .
Chapter Two : Branching
a. Branching by using ( If Then )
Form of Statement :
If ( condition expression ) Then
Code The codes that will be executed when the result of the
conditional expression is ( True ) .
End If
A. If the condition is ( True ) :
- The codes following ( Then ) will be executed sequentially until
( End If ).
B- If the condition is ( False ) :
- The conditions following ( Then ) will not be executed and the
conditional statement will end while the codes following ( End
If ) will be executed, if there.
- MsgBox :it is used to display a message box with contents to be
renewed .
The Conditional Expression :
Definition :
- An expression of the relation between two values . The value may
be : abstract value , constant ,variable , or property .
- Also , we can say that , it is a part of the programming code and
the result is either ( True ) or ( False ) according to the value of a
property, variable , or other data in the program .

138

The Comparison Factors :


Operator
=
<>
>
<
>=
=<

Identification
Equal
Not equal
Greater than
Less than
Greater than or equal to
Less than or equal to

Second : Branching by using ( If Then .. Else ) :


The Form :
If Conditional Expression , then :
Code The codes that will be executed if the condition is ( True ) .
Else
Code The codes that will be executed if the condition is ( False ) .
End If
- This statement is used when there are two options in the
conditional statement .
a. If the condition is ( True ) :
- The codes following (Then )will be executed.
b.If the condition is ( False ) :
- The codes following( Else )are executed .
Branching by using ( If Then .. Else If )
The Form :
If Condition ( the first condition ) Then :
Code the codes that will be executed if the first condition is ( True )
Else If Condition ( the second condition ) Then :
Code the codes that will be executed if the second condition is ( True )
Else

139

Code

the codes that will be executed if any of the previous codes


are not (True)

End If
Using (IsNumeric) :
- It is a predefined function in VisualBasic.Net and it is used to
identify the content of Textbox or the content of the variable and
whether it is a number or a character.
a- when the functions value is numeric : True
b- When the functions value is non - numeric : False .
The Form
IsNumeric( Parameter )
1- Variable .
2- Property .
( Focus ) Method :
- Indicates to the attention or concentration so the typing pointer
appears in this tool .
The Logical Operators :
The Logical Operator ( And ) :
- It is used for combining two conditions , the result will be
( True ) , when the two conditions are ( True ) .
( True And True True )
The Logical Operator ( Or ) :
- It is used for combining two conditions and the final result will be
( True ) if the value of one condition is ( True ) or both of them.
True Or True True
True Or False True

140

Branching by using ( Select . Case ) :


- This statement is used when there are several conditions and we
need to identify the true condition and execute codes which are
based upon it .
- This statement has the same use as ( If Then . Else If )and it
is more suitable when the branching depends on the value of one
variable only .
Formation :
Select Case Variable
Case Value1 The variables first value
Code The codes which need to be executed when using the
variables first value
Case Value2 The variables second value
Code The codes which need to be executed when using the
variables second value
Case Value3 The variables third value
Code The codes which need to be executed when using the
variables third value
Case Else
Code The codes that will be executed if the variables will not
take any of the previous values
End Select
( SelectedIndex ) Property :
- It is used in determining and identifying the selected item from
ListBox or ComboBox.
( SelectedIndexChanged ) Event :
- This event occurs when selecting an item from ListBox or
ComboBox during the program runtime.

141

Chapter Three : Loops and Timers


1- Using ( For . Next )statement .
The common form of the statement :
- For Variable Counter = Start To End
- This statement is used for repeating a code or a set of codes for a
certain number of times .
How to execute ( For . Next ) statement :
1- First save the Start value in the Counter .
2- Compare the value in the counter with the End value .
3- If the Counter value is less than or equals to the End value , the
codes in For .. Next, is executed sequentially.
4- If the Counter value is greater than the End value , the repetition
stops and the codes following Next are executed , if there .
5- When reaching Next ,the Counter is increased upon the
increment value after Step .
6-When there is no increment , the Counter will be increased with
the default value which is ( 1 ) .
- The increment step is optional that can be typed or not .
- The variable name after Next can be typed or not , and when not
typing it , the variable after For is used .
Example :
For S = 1 To 5
( The repetition value is five times ).
For S = 1 To 10 Step 3 ( The repetition value is four times ).
- Start value can be greater than End value and here the increment
step should be typed and it should be in minus .
- Start value ,End value and the increment step may contain
decimals so , the type of the used variables should be set to use
decimals .

142

Using ( Do . While ) Statement :


- This statements used for repeating a code or set of codes based on
the condition result .
Form of Statement :
Do while The conditional Expression
Code The codes that will be repeated
Loop
a. When the condition is ( True ) the codes between ( Do While ,
Loop ) are executed .
b. When the condition is ( False ) the codes between ( Do While ,
Loop ) are not executed and the repetition stops.
Using the ( Timer ) tool :
Function :
- The Timer tool is used for repeating the execution of a code
periodically or for executing a code for a certain period of time.
- In this tool , the execution of the codes is related to the time .
Properties :
1- Enabled : To start or stop the Timer and its default value is
( False ) .
- To start the Timer ,we should first convert the property Enabled
value into True .
2- Interval :
- It is a property which sets the period after which the Timer will be
active , that all the related codes will be executed .
- The value of the Interval property is in millisecond .
1 Second = 1000 millisecond
( Tick ) event :
- It is the event of the Timer tool and it is activated after the set
period in the Interval property is passed .

143

Now

To display the current time and date in the


computer and it does not use any parameters .
TimeofDay To display only the set current time in the
computer.
Example :
- MsgBox( Now ).
- MessageBox. Show ( TimeofDay )
Chapter Four : Procedures :
Procedure
1- Definition :
- It is a set of instructions and codes which has a certain title and
when calling it , those codes and instructions will be executed .
2- Types of Procedures :
The Procedure ( Sub ) :
- This procedure has no value , but , it presents a code that can be
used in several locations in ( Class ) .
- So , the goal of this type is :
a. It saves time and effort .
b. Helps typing the code and facilitates its reading , understanding
and modifying .
- The general formula for ( Sub ) declaration :
Sub Name ( Parameter )
Code The codes that will be executed when calling it .
End Sub
- Sub Name : The name of the sub
- Parameters :They are the values that will be received when
calling the procedure to execute the codes .

144

The ( Function ) procedure :


- ( Function ) has a value that it is used when there is a code that
will give a value we need to use and input in other codes .
The Formula for declaring ( Function ) :
(1)
(2)
(3)
Function Name ( Parameters ) AS Data Type
Code ( 4 )
Return Value ( 5 )
End Function
1- Function Name : name of the Function factor .
2-Parameters :the factors or parameters that will be used in the
code .
3- Data Type :the type of the data about the return value .
4- Code :the codes that will be executed when calling the function .
5- Value :it is the return value from the function .
The Predefined Functions :
- Definition :
- They are predefined functions in the programming language , and
when we want to use them , they are called without declaration .
- They are functions which have defined functions or values in
VisualBasic.Net .
Examples of some Predefined Functions :
First : Show
- It is used in ( Message Box ) to view a message box and its
contents can be set based on the defined factors or parameters .
Second : IsNumeric
- It is used to check any value whether it is numeric or not .
- The result can be as the following :
a. True :when it is numeric .

145

b. False : when the value is not numeric and cant be changed


into numeric.
- When calling this function ( True or False ) appears.
Third : Now
- It is used to display the set date and time in the computer.
- Now does not use any parameters .
Example :
- MessageBox . Show ( Now )
Chapter Five : Cyber Bullying :
Cyber Bullying Definition :
Is an intentional aggressive behavior using electronic media for the
purpose of harassment or embarrass or scare or threaten others .
The Electronic media for cyber Bullying :
From the electronic media that the cyber bully uses are :
1- E-mail . 2 - Electronic forums. 3- Instant Message.
4 - Blogging .
5-Social networking sites such as (FaceBook).
Cyber Bullying Forms :
From the cyber bulling forms which the internet or electronic media
user might be exposed to :
1 - Anonymity .
2 - Harassment .
3- Cyber Stalking .
4 - Flaming .
5 - Outing . 6 - Exclusion . 7- Cyber Threats .
How can you protect yourself from
cyber bullying ?
1 - Do not share a password..
2 - Choose a password that is difficult for someone else to guess
(using a combination of letters and numbers).
3 - Do not Post any private data on the Internet through any service
or any site.
4 - Do not delete a cyber bullying mail messages, (where it can be a
tool and evidence against the cyber bully).
5 - Do not meet anyone you know through the Internet.
6 - Do not rush to send an email and you are angry.

146

Das könnte Ihnen auch gefallen