انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Lecture 3 -Varibles and Math Operations

Share |
الكلية كلية تكنولوجيا المعلومات     القسم قسم شبكات المعلومات     المرحلة 1
أستاذ المادة نوفل تركي عبيس الجميلي       18/12/2016 21:34:52
Using Variables to Store Information
In the bakery application from Chapter 2, all of the sales information is temporarily stored
in the properties of the controls on the sales receipt form. For example, the numbers
of doughnuts and muffins sold are stored in the Text properties of the txtDonuts and
txtMuffins controls, respectively. Recall that the btnCalc_Click procedure uses the
Text properties of those controls to calculate the total number of items sold, like this:
lblTotalItems.Text = Val(txtDonuts.Text) + Val(txtMuffins.Text). The
procedure then uses the lblTotalItems control’s Text property to calculate the total sales
amount, like this: lblTotalSales.Text = Val(lblTotalItems.Text) * 0.5.
Besides storing data in the properties of controls, a programmer can also temporarily store data
in memory locations inside the computer. The memory locations are called variables because
the contents of the locations can change (vary) as the application is running. It may be helpful
to picture a variable as a small box inside the computer. You can enter and store data in the box,
but you cannot actually see the box. One use for a variable is to hold information that is not
stored in a control on the form. For example, if you didn’t need to display the total number of
items sold on the bakery’s sales receipt, you could eliminate the lblTotalItems control from the
form and store the total number of items sold in a variable instead. You then would use the value
stored in the variable, rather than the value stored in the control’s Text property, in the total
sales calculation.
You can also use a variable to store the data contained in a control’s property, such as the data
contained in a control’s Text property. Programmers typically do this when the data is a numeric
amount that will be used in a calculation. As you will learn in the next section, assigning
numeric data to a variable allows you to control the preciseness of the data. It also makes your
code run more efficiently because the computer can process data stored in a variable much
faster than it can process data stored in the property of a control.
Every variable has a data type, name, scope, and lifetime. First, you will learn how to select an
appropriate data type for a variable

المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم