computer__revision_3prepU867z
computer__revision_3prepU867z
Chapter One: Data Types Constants They are places reserved in the (RAM) and, have
data types.
In VB.net language, there are many Data Types.
You should be declaring the constants and assigning values of
Some Data Types provided by (Visual Basic.Net) are : them.
1) Numerical: These values are a fixed and cannot be changed during
a- Integral : ( Byte – Long – Integer – Short ). program execution.
b- Non Integral : ( Double – Single –
Decimal ). Declaring Constants:
2) Character : ( String – Char ). We use the ( Const) keyword to declare constants.
3) Miscellaneous : ( Object – Date – Boolean).
Each classification of Data Type has more than one type.
Each Data Type has: The double quotes " " are used if the value of variable or
A storage space in the memory: for example the data type constant is a string value.
(Integer); when used, it occupies (4 bytes) . The hashes # # are used if the value of variable or constant is
A range of values (minimum value and maximum value); for date or time.
example the range of values for the data type (Byte) starts with Naming Rules Variables & Constants:
‘0’ and ends with ‘255’. 1) Variable or Constant names must begin with a letter or
Variables are reserved places in computer memory (RAM) to underscore ( _ ).
store values temporarily, these values change during the 2) Variable or Constant names should not contain symbols or
running of program. special characters (e.g.: ?, *, ^, -, +, ….. etc. ) .
Each Variable has a name and Data type. 3) Variable or Constant names consist of letters, numbers, and
These Data Types are created by declaring variables then underscores ( _ ).
assigning values to them depending on their Data Types. 4) Do not use reserved words (Visual Basic.NET Language
Keywords) such as (single, Dim, As).
Declaring Variables: 5) It is preferable that the Variable or Constant name reflects
We use "Dim" keyword to declare the variable. its content.
1
Computer 3rd.Prep Second Term
3
Computer 3rd.Prep Second Term
Chapter Three: Looping & Procedures The statements (VB code) are repeated inside the loop until the
counter value reaches the End value.
Looping using (For…Next):
It is one of the limited loop statements used when we want to If the value of the increment is positive 1, it can be dispensed
repeat a code for specific number of time. with writing (Step Add Value) as the default value to increase the
counter positive 1.
The syntax of the (For…Next) statement
Looping using (Do While… Loop):
For Variable = Start Value To End Value [Step Add Value]
VB code The syntax of the (Do While…..Loop):
Next [Variable] Do While Conditional Expression
VB code
Loop
The (Do While...Loop) is used to repeat a specific code for a
several times of an unknown end, but based on a specific
condition, so it is useful if you do not know the number of
iterations .
The (For...Next) statement should start with the Keyword (For) The code between the beginning of the loop "Do While" and its
and end with the Keyword (Next). end will be implemented as long as the conditional expression is
true.
"Variable" is the name which represents the counter and its
If the condition is not met for any reason, we get out of the
type must be numeric (integer or decimal).
iterative loop, and implement the code after the Loop if it exists.
"Start Value" is the start value of the counter or the beginning of Procedure
repetition is a numeric value. A set of commands and instructions under a name, can be
"End Value" is the value of the end of the counter and the end of recalled by that name, to implement them, and create a (Sub) if
the repetition is also a numeric value. we have a set of commands that are frequently used in more than
"Add Value" is the increment value of the counter or value over one place in the class.
the counter until it reaches the end value. Procedures must be called by their names.
"Code" is one or more commands to be replicated between the Calling a procedure causes the program to execute
beginning of loop (For) and its end (Next). procedure's statements or code.
4
Computer 3rd.Prep Second Term
Variables and constants, that can be declared either within Declaring and using parameters:
the scope of the (Event procedures) or within the (Class). To solve the previous problem, the procedure
You can declare the Procedures, this declaration is done only (ShowOddOrEven) must receive the values (1) or (2) on
once, but you recall the procedures many times from anywhere recalling it. this value is used to specify whether the odd
in your program. numbers will be displayed or the even numbers will be
There are two types of procedures in Visual Basic .NET: displayed. So we add the variable (Start) that will be called later.
Sub procedures()اﺟﺮاء ﻓﺮﻋﻰ
Sub procedures do not return a value ( ),ﻻﻳﻌﻮد ﺑﻘﻴﻤﺔwhile
Functions ( )اﻟﺪاﻟﺔprocedures.
Functions return a value.
Declaration of Sub Procedures: In figure, a sub Procedure of the name (ShowOddOrEven) has
You can declare a Sub procedure in a class; if we had a code that been declared and a Parameter named (Start) has been also
will be repeated in more than one place in this Class; as well as declared. And used in the code to specify the starting value of
for the organization of this code, and so it will be easy to read and the iteration (repetition), accordingly it display.
understand. Declaration of Function Procedures:
And then modify it if necessary. Function is a set of commands under a particular name that
Declaration Syntax: should express its task. It is applied to Parameters and Returns a
Sub Name (Parameters) value
Code Declaration Syntax:
End Sub Function Function Name (Parameters) As Data Type
Code
1) "Name" reflects the name of the procedure. Return Value
2) "Parameters" reflect the values that were used inside the End Function
procedure code that are used on recalling the procedure. Where:
3) "Code" is a set of orders and instructions carried out on 1) "Name" expresses the name of the function.
recalling the procedure (Sub). 2) "Datatype" identifies the type of the returned value of the
function.
5
Computer 3rd.Prep Second Term
Remember:
1) Variables: We can assign values to Variables; during the
declaration and the execution of the Program instructions, as
well as using these values stored.
2) Constants: We can assign values to Constants; during the
declaration only, as well as using these values stored.
3) Functions: We cannot assign values to Functions, but
function can be called and returns a value in the light of the
values assigned to the function, as well as using this value Chapter Four: Cyber Bullying
stored. There are many risks that we can be exposed to, including:
getting wrong information.
Remember: falling prey to some of the aggressors across modes of
It is preferred when naming Functions; give names related to
electronic communication.
their functionality. You can:
violation of privacy.
1. Declare a Function.
identity theft.
2. Determine its Parameters.
getting our account stolen (on the social networking sites like
3. Specify the Function type.
Facebook or email).
4. Write Code within this Function.
Subjecting our system to the risk of infection by viruses or
5. Return a value using the Return statement.
spyware, or software piracy and others. • getting wrong
information.
6
Computer 3rd.Prep Second Term