Beruflich Dokumente
Kultur Dokumente
- II
ASSIGNMENT # 1
Submitted to: Sir Asim Iftikhar
By: Amna Mushtaq Khan
14446
1. Byte
A byte is a small natural positive number that ranges from 0 to 255. A variable of
byte type can be used to hold small values such as a person's age, the number of
fingers
on
an
animal,
etc.
To declare a variable for a small number, use the Byte keyword. Here is an example:
Private Sub Form_Load()
Dim StudentAge as Byte
End Sub
2. Boolean
A Boolean variable is one whose value can be only either True or False. To declare
such a variable, use the Boolean keyword. Here is an example,
Private Sub Form_Load()
Dim IsMarried as Boolean
End Sub
After declaring a Boolean variable, you can initialize by assigning it either True or
False. Here is an example,
Private Sub Form_Load()
Dim IsMarried As Boolean
IsMarried = False
End Sub
3. Integer
An integer is a natural number larger than the Byte. It can hold a value between
-32,768 and 32,767. Examples of such ranges are: the number of pages of a book.
To declare a variable of type integer, use the Integer keyword. Here is an example:
Private Sub Form_Load()
Dim MusicTracks As Integer
End Sub
4. Long Integer
A long integer is a natural number whose value is between 2,147,483,648 and
2,147,483,642. Examples are the population of a city, the distance between places
of different countries, the number of words of a book.
To declare a variable that can hold
the Long keyword. Here is an example:
very
large
natural
number,
use
Sub Form_Load()
StudentAge As Byte
Tracks As Integer
Population As Long
Distance As Single
7. Currency
The Currency data type is used for a variable that can hold monetary values. To
declare such a variable, use the Currency keyword. Here is an example:
Private Sub Form_Load()
Dim Population As Long
Dim Distance As Single
Dim StartingSalary As Currency
End Sub
8. String
A string is an empty text, a letter, a word or a group of words considered. To declare
a string variable, use the String data type. Here is an example:
Private Sub Form_Load()
Dim CountryName As String
End Sub
If you want to store something in the memory space allocated to the variable,
assign it a word or group of words included between double-quotes. Here is an
example:
Private Sub Form_Load()
Dim CountryName As String
CountryName = "Great Britain"
End Sub
9. Date
A date is a numeric value that represents the number of days that have elapsed
since a determined period. A time is a numeric value that represents the number of
seconds that have elapsed in a day.
To declare a variable that can hold either date values, time values, or both, use
the Date keyword. After the variable has been declared, you will configure it to the
appropriate value. Here are two examples:
Private
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Sub Form_Load()
CountryName As String
IsMarried As Boolean
StudentAge As Byte
Tracks As Integer
Population As Long
Distance As Single
StartingSalary As Currency
DateOfBirth As Date
KickOfTime As Date
End Sub