7/25/2019 Lecture 3 Variables,Constants,Calculations EDITED
1/21
LECTURE 3
7/25/2019 Lecture 3 Variables,Constants,Calculations EDITED
2/21
3- 2
Temporary memory locations that have: a name
a data type, and
a scope.The name given to the location is called
identifer. The value stored in a variable can be changed
during the execution o the project
The values stored in constantscannotchange
7/25/2019 Lecture 3 Variables,Constants,Calculations EDITED
3/21
3- 3
!ariables and "amed #onstants must bedeclared beore being used in code
$hen you declare a !ariable or "amed#onstant !%
&eserves an area o memory
'ssigns it a name called an (dentifer
)eclaration statements are coded either
%eginning o a procedure
*eneral )eclarations o a module
7/25/2019 Lecture 3 Variables,Constants,Calculations EDITED
4/21
3- +
DIMused to declare !ariables CONSTused to declare "amed #onstants )eclaration includes
"ame, ollo "aming #onvention &ules
)ata Type
&euired !alue or #onstants
ptional (nitial !alue or !ariables
7/25/2019 Lecture 3 Variables,Constants,Calculations EDITED
5/21
3- /
Boolean
Byte (0 to 255)
Char
Date
String
Decimal
Object Short (-32,768 to 32,767)
nteger
!("2,#$7,$8%,6$8 to
2,#$7,$8%,6$7)
&ong (larger 'holenmber)
Single (*loating +oint accracy to 6
igit) Doble
!(*loating +oint accracy to 14
+oint)
7/25/2019 Lecture 3 Variables,Constants,Calculations EDITED
6/21
3- 0
%oolean 1 2 bytes %yte 1 byte #har 1 2 bytes
)ate 1 bytes 4tring 1 varies )ecimal 1 0 bytes bject 1 + bytes
4hort 1 2 bytes (nteger 1 + bytes 5ong 1 bytes
4ingle 1 + bytes )ouble 1 bytes
7/25/2019 Lecture 3 Variables,Constants,Calculations EDITED
7/213- 6
%oolean 1 bln %yte 1 byt #har 1 chr
)ate 1 dat 4tring 1 str )ecimal 1 dec bject 1 depends
on type o object
4hort 1 sht (nteger 1 int 5ong 1 lng
4ingle 1 sng )ouble 1 dbl
7/25/2019 Lecture 3 Variables,Constants,Calculations EDITED
8/213-
Dim strName, strSSN As StringDim intAge As Short
DimdecPayRate As Decima ! "#$%InitializationDim dat&ireDate As DateDim 'nIns(red As )ooeanDim ngPo*(ation As Long
ConstdecDISCOUNT+RATE As Decima ! #%Fixed
Note:Constants are named using all uppercase
letters EXCEPT the prefix.
7/25/2019 Lecture 3 Variables,Constants,Calculations EDITED
9/213- 7
#alculations can be perormed usingproperties o certain objects, variables,constants, and numeric literals
)o "ot use 4trings in calculations !alues rom Text property o Text %oxes 're 4trings, even i they contain numeric data
8ustbe converted to a "umeric )ata Type
7/25/2019 Lecture 3 Variables,Constants,Calculations EDITED
10/213- 9
#alculations may be perormedusing the values o
numeric variables,
constants, and
properties o controls.
The result o a calculation may be
assigned toa n(meric -aria'e orto the *ro*erty o. a contro#
7/25/2019 Lecture 3 Variables,Constants,Calculations EDITED
11/213-
unctions perorm an action and return avalue
;xpression to operate on is called the
'rgument #onversion unctions convert arguments into
a numeric value o the correct data type
#onversion unctions on Text %oxesailiuser enters nonnumeric data or leaves the
Text %ox blan
Top Related