6. Each data type has:
1. A storage space in the memory: such as (Integer) when used It occupies (4 bytes).
2- A range of values: minimum and maximum range of values type
Ex: (Byte) starts with "0" and ends with "255".
7. Constants and Variables
Variables Constantans
Defenition
Are reserved Places in the computer 's
memory that have Names and Data types
that store values that can be changed during
the execution of program
Are reserved Places in the computer 's memory that have
Names and Data types that store values that can not be
changed during the execution of program
Declaratio
n
Dim
Dim Variable name As data Type
Const
Const constant name As Data Type = Value
Ex
Dim UserName As String Const Pi As Single =22/7
8. Rules for naming the Constants and variables: :
1. names must begin with a letter or underscore (_).
2. names Should not contain symbols or special characters
(e.g.: ?,*,^, -, +,.)
3. Variable names consist of letters, numbers, and underscores (_).
4. Do not use reserved words (Visual Basic.NET Language Keywords)
such as (single, Dim, As).
5. It is preferable that the Variable name reflects its content.
9. 1- Text valves are written between double quotes (" ")
Const Cinema As string = "Royal"
2- (# #)are used while writing date or time.
Const Birthdate As Date= #1/7/2011#
Assignment statement:
10. Examples of values of assignment ststment
1) Abstract Value : Ex: Area =5 Text = "Egypt"
2) (Value from Variable ): Area = N1
3) (Value from Property): Name = TextBox1.Text
4) ( Value from expression): Area = Num1 +3
5) ( value from function) :Name= Sum(A,B)
6) (Value from Constant) : Area =3.14*R^2
11. Assignment Statement for Variables
Dim Number As Integer
Number = 500
Dim Number As Integer =500
1st
Case :(we can write the assignment statement after declaration line)
2nd
Case : (we can write the assignment statement during declaration in the same line)
Const Pi AS Single =22/7
Assignment Statement for Constants has One case:- must be during declaration only