You are on page 1of 3

ASSIGNMENT NO.

2 TOPIC: INTRODUCTION TO OOP

Jun. 25, 12

1. Types of Data We'll talk about data in lots of places in The Knowledge Base, but here I just want to make a fundamental distinction between two types of data: qualitative and quantitative. The way we typically define them, we call data 'quantitative' if it is in numerical form and 'qualitative' if it is not. Notice that qualitative data could be much more than just words or text. Photographs, videos, sound recordings and so on, can be considered qualitative data. 2.1 NAMING A VARIABLE

The name must being with a letter of the alphabet. The name must consist only of letters, digits, and the underscore character. (No punctuation marks are allowed.) The name can be as long as 255 characters. Variable names cant be duplicated with the same scope. This means, for example, that you cant have two variables of the same name within a procedure. You can, however, have two variables with the same name in two different procedures. 2.2 VARIABLE SCOPE

The scope of a variable is determined at the time the variable is declared. In Microsoft Visual Basic for Applications, the three scopes available for variables are procedure, module, and public. The "More Information" section of this article describes each scope in detail.

2.3

VARIABLE DECLARATION

Declaration Levels Local and Member Variables A local variable is one that is declared within a procedure. A member variable is a member of a Visual Basic type; it is declared at module level, inside a class, structure, or module, but not within any procedure internal to that class, structure, or module. Shared and Instance Variables In a class or structure, the category of a member variable depends on whether or not it is shared. If it is declared with the Shared keyword, it is a shared variable, and it exists in a single copy shared among all instances of the class or structure.

PEREZ, JOHN RAYMOND S. BIT 3C-G1

Page | 1

ASSIGNMENT NO. 2 TOPIC: INTRODUCTION TO OOP

Jun. 25, 12

Otherwise it is an instance variable, and a separate copy of it is created for each instance of the class or structure. A given copy of an instance variable is available only to the instance for which it was created. It is independent of a copy in any other instance. Declaring Data Type The As clause in the declaration statement allows you to define the data type or object type of the variable you are declaring. You can specify any of the following types for a variable:

An elementary data type, such as Boolean, Long, or Decimal A composite data type, such as an array or structure An object type, or class, defined either in your application or in another application A .NET Framework class, such as Label or TextBox An interface type, such as IComparable or IDisposable

You can declare several variables in one statement without having to repeat the data type. In the following statements, the variables i, j, and k are declared as type Integer, land m as Long, and x and y as Single: Dim i, j, k As Integer ' All three variables in the preceding statement are declared as Integer. Dim l, m As Long, x, y As Single ' In the preceding statement, l and m are Long, x and y are Single. For more information on data types, see Data Types in Visual Basic. For more information on objects, see Object-Oriented Programming in Visual Basic and Programming with Components. Declaring Characteristics The lifetime of a variable is the period of time during which it is available for use. In general, a variable exists as long as the element that declares it (such as a procedure or class) continues to exist. In some cases it is possible to extend a variable's lifetime. For more information, see Lifetime in Visual Basic. The scope of a variable is the set of all code that can refer to it without qualifying its name. A variable's scope is determined by where it is declared. Code located in a given region can use the variables defined in that region without having to qualify their names. For more information, see Scope in Visual Basic. A variable's access level is the extent of code that has permission to access it. This is determined by the access modifier (such as Public (Visual Basic) or Private (Visual Basic)) that you use in the Dim statement. For more information, see Access Levels in Visual Basic.

PEREZ, JOHN RAYMOND S. BIT 3C-G1

Page | 2

ASSIGNMENT NO. 2 TOPIC: INTRODUCTION TO OOP

Jun. 25, 12

3.

CONSTANTS

A constant is a meaningful name that takes the place of a number or string that does not change. Constants store values that, as the name implies, remain the same throughout the execution of an application. You can greatly improve the readability of your code and make it easier to maintain by using constants. Use them in code that contains values that reappear or that depends on certain numbers that are difficult to remember or have no obvious meaning. 4. CONCATINATING STRINGS

In computer programming, string concatenation is the operation of joining two character strings end-to-end. For example, the strings "snow" and "ball" may be concatenated to give "snowball". In many programming languages, string concatenation is a binary infix operator. For example, the following expression uses the "+" symbol as the concatenation operator to join two strings: "Hello, " + "World";, and has the value "Hello, World".

PEREZ, JOHN RAYMOND S. BIT 3C-G1

Page | 3

You might also like