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

Lecture-7: Variables and Constants

Share |
الكلية كلية هندسة المواد     القسم قسم البوليمرات والصناعات البتروكيمياوية     المرحلة 2
أستاذ المادة حسين محمد سلمان الشمري       09/12/2015 19:42:54
Lecture-7: Variables and Constants

Variables are locations in memory used by Visual Basic to hold data and/or information needed by your application.
Rules used in naming variables:
1. Must begin with letter.
2. Can’t contain an embedded type-declaration character.
3. Must not exceed 255 characters.
4. They can’t be the same as restricted keywords (a restricted keyword is a word that Visual Basic uses as part of its language. This includes predefined statements such as “If and Loop”, functions such as “Len and Abs”, and operators such as “Or and Mod”).

Visual Basic Data Types


Variable Declaration
There are three ways for a variable to be typed (declared):
1. Default
2. Implicit
3. Explicit
1: Default If variables are not implicitly or explicitly typed, they are assigned the variant type by default. The variant data type is a special type used by Visual Basic that can contain numeric, string, or date data.
2:Implicitly To implicitly type a variable, use the corresponding suffix shown above in the data type table. For example,

TextValue$ = "This is a string" creates a string variable, while
Amount% = 300 creates an integer variable.
3:Explicitly There are many advantages to explicitly typing variables. Primarily, we insure all computations are properly done, mistyped variable names are easily spotted, and Visual Basic will take care of insuring consistency in upper and lower case letters used in variable names. Because of these advantages, and because it is good programming practice, we will explicitly type all variables.


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