Page 84 - Open Soource Technologies 304.indd
P. 84

Event Driven Programming



                          Objectives

                          After studying this unit, you will be able to:
                            • Understand the various data types and its variables
                            • Discuss the variables and its various declaration
                            • Explain the Dim statement
                          Introduction


                          Calculations and data storage is basic building block of any programming language. So it is very
                          important to understand them in Visual Basic. Although the calculations themselves are quite
                          simple , but there are some important issues to be understood along with them like how to store
                          data, what data types are allowed in Visual Basic, where and when to declare variables and
                          constants and most importantly the type compatibility among various data types.

                          4.1 Data Types

                          Data type determines type of data variable can store. In all programming languages, you define
                          a real-world data that refers to some specific type and needs to be understood by the compiler.
                          The compiler of the language defines the rules for different types of data that is to be allowed. This
                          type could be numeric, a string user defined or date. All compilers are CLS(Common Language
                          Specification) compliant  i.e., it allows for certain data types. It enables cross-language program-
                          ming. This interoperability ensures that if you write an application in suppose Visual Basic and
                          the datatypes used are CLS compliant then any other language Framework can exchange informa-
                          tion with the application. A list of Visual Basic’s simple data types are given below:

                          1. Numeric
                             Byte            Store integer values in the range of 0 - 255
                             Integer         Store integer values in the range of (-32,768) - (+ 32,767)
                             Long            Store integer values in the range of (- 2,147,483,468) - (+ 2,147,483,468)

                             Single          Store floating point value in the range of (-3.4x10-38) - (+ 3.4x1038)
                             Double          Store large floating value which exceeding the single data type value
                             Currency        Store monetary values. It supports 4 digits to the right of decimal point
                                             and 15 digits to the left


                          2. String
                          Use to store alphanumeric values. A variable length string can store approximately 4 billion
                          characters.

                          3. Date
                          Use to store date and time values. A variable declared as date type can store both date and time
                          values and it can store date values 01/01/0100 up to 12/31/9999.




                          78                     LOVELY PROFESSIONAL UNIVERSITY
   79   80   81   82   83   84   85   86   87   88   89