Presentation is loading. Please wait.

Presentation is loading. Please wait.

Representing Data: Constants and Variables CHAPTER THREE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009.

Similar presentations


Presentation on theme: "Representing Data: Constants and Variables CHAPTER THREE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009."— Presentation transcript:

1 Representing Data: Constants and Variables CHAPTER THREE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009

2 Bina Nusantara University 2 Chapter Introduction Compose event procedures that perform more sophisticated tasks. Focus specifically on data items. Continue work with Visual Basic.NET project structure. Determine the meaning of the term scope.

3 Bina Nusantara University 3 Objectives Differentiate between numeric and string data. Determine whether a data item should be a constant or variable. Code constants and variables in event procedures. Describe the characteristics and uses of standard data types. Create projects that consist of several forms. Explain scope and describe the domain of variables in procedures and forms.

4 Bina Nusantara University 4 3.1 Data Categorization Two broad categories of data are numeric and string. –Numeric data must contain only numbers. –String data can contain any symbol. –Numeric data is used in arithmetic calculations. –String data cannot be used in calculations.

5 Bina Nusantara University 5 3.2 Constants Data item whose value is assigned at design time and remains the same at run time. A literal constant is just a value. A symbolic constant is a descriptive name substituted for a literal constant.

6 Bina Nusantara University 6 Standard Data Types Number of Bytes –Main memory occupied by a variable. Range –Largest and smallest values that can be stored in a numeric variable of a given type.

7 Bina Nusantara University 7 Standard Data Types (cont.) Precision –Indicates how close together two numeric values can be. Speed of Arithmetic Calculation –Differs for the different data types.

8 Bina Nusantara University 8 Choosing the Best Data Type for a Variable Use decision rules –Ex. Boolean is the best type for a variable that may be true or false. –Ex. Decimal is the best type for a dollar amount.

9 Bina Nusantara University 9 Declaring Variables: The Dim Statement A variable declaration statement. –Examples: Dim StreetAddress As String Dim GrossWeight As Integer Dim HomePhone As String Dim NetIncome As Decimal Dim CurrentStudent As Boolean

10 Bina Nusantara University 10 Using Variables: The Assignment Statement Syntax of the Assignment Statement –variablename = expression Ex. CourseCode = “CISB119” Run Time: The Effect of the Assignment Statement –Evaluates expression on right side of equal sign. –Stores value of expression in variable on left side of equal sign.

11 Bina Nusantara University 11 Appearance and Use Multiple forms may be used for large projects. –Each form should represent an objective. –Each form should be clear and attractive. Each form is a user interface window during run time. All forms have the same basic components.

12 Bina Nusantara University 12 Properties of the Form Control (Name) AcceptButton BackColor CancelButton ControlBox Font MaximizeBox MinimizeBox Text

13 Bina Nusantara University 13 Form as a Class You create a class template by creating a form. Buttons and text boxes are added to the class definition. Events are methods added to the form class. Many properties and methods are inherited from the form’s superclass.


Download ppt "Representing Data: Constants and Variables CHAPTER THREE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009."

Similar presentations


Ads by Google