Sie sind auf Seite 1von 7

VB.NET Brief Introduction.

Visual Basic .NET (VB.NET) is an object-oriented computer programming language


that can be viewed as an evolution of Microsoft's Visual Basic (VB) which is
generally implemented on the Microsoft .NET Framework.

.NET Framework what it is?

(Features: What the .NET Framework is supposed to do. )

The .NET Framework is an integral Windows component that supports building and
running the next generation of applications and XML Web services.

• To provide a consistent object-oriented programming environment whether


object code is stored and executed locally, executed locally but Internet-
distributed, or executed remotely.
• To provide a code-execution environment that minimizes software
deployment and versioning conflicts.
• To provide a code-execution environment that promotes safe execution of
code, including code created by an unknown or semi-trusted third party.
• To provide a code-execution environment that eliminates the performance
problems of scripted or interpreted environments.
• To make the developer experience consistent across widely varying types of
applications, such as Windows-based applications and Web-based
applications.
• To build all communication on industry standards to ensure that code based
on the .NET Framework can integrate with any other code.

(The Parts of .NET Framework)

The .NET Framework has two main components: the common language runtime
and the .NET Framework class library.

The common language runtime is the foundation of the .NET Framework. You can
think of the runtime as an agent that manages code at execution time, providing
core services such as memory management, thread management, and remoting,
while also enforcing strict type safety and other forms of code accuracy that
promote security and robustness.

The other main component of the .NET Framework is the Class Library which is a
comprehensive, object-oriented collection of reusable types that you can use to
develop applications ranging from traditional command-line or graphical user
interface (GUI) applications to applications based on the latest innovations provided
by ASP.NET, such as Web Forms and XML Web services.
Variables and Data types
The Variable in a Computer Refers to a place in the computer’s memory where data can be
stored. A Variable can be visualized as a box with a name. The box can contain only a specific
value depending on the Type (i.e. Data type) of the box.
In its roots the Data can be of “Numerical” or “Character” or “Binary” form.
Variable can hold amount of data depending on its size.
All Variables are finally stored on the memory in Binary form, which is the task of the operating
system and the Compiler.
Numerical Data Refers to:
Decimals 0 to 9, Hexadecimals 0 to F and Octal 0 to 7
Note that a Number is referred to as a value on which mathematical calculations can be
done such as Addition, Subtraction, Division, Multiplication and more.
Again the Numerical datatypes are divided into two parts:
Whole Numbers (Numbers that do not have fractional parts 35, 36, 5600, -0988 including
positive, negative and Zero )
and
Real Numbers(Any Number with or without decimal place and of any sign)
Common Numerical Data Types in VB.NET are :
(Whole Number data type)
Character Data Refers to:
Characters: There are in All 256 Characters on the ASCII set, The UNICODE set
contains more characters.
Note that Character includes “a-z”, “A-Z”, “0-9”, “! @#$%^&*()_+=-|{}[]:”;’< >,.?/~`”
Space, Tab, Vertical Tab, Enter, Backspace are also considered characters, they are
called whitespace characters, or non printable characters.

The Basic Data Types:

Datatypes in a programming language describes that what type of data a variable can hold . When we
declare a variable, we have to tell the compiler about what type of the data the variable can hold or which
data type the variable belongs to.
Field Information:

Visual Basic Type: the Common name of the Datatype

CLR Type Structure: The Class library that contains the Datatype

Nominal Storage Allocation: Specifies the amount of bytes allocated in memory.

Value Range: The Value range within which it is safe to use these data types, outside which the rounding
effects or spurious value generation will occur.

Visual Basic Common language runtimeNominal storageValue range


type type structure allocation

Boolean System.Boolean 2 bytes True or False.

Byte System.Byte 1 byte 0 through 255 (unsigned).

Char System.Char 2 bytes 0 through 65535 (unsigned).

Date System.DateTime 8 bytes 0:00:00 on January 1, 0001 through 11:59:59 PM on


December 31, 9999.

Decimal System.Decimal 16 bytes 0 through +/-


79,228,162,514,264,337,593,543,950,335 with no
decimal point;
0 through +/-7.9228162514264337593543950335
with 28 places to the right of the decimal; smallest
nonzero number is
+/-0.0000000000000000000000000001 (+/-1E-28).

Double System.Double 8 bytes -1.79769313486231570E+308 through


(double- -4.94065645841246544E-324 for negative values;
precision 4.94065645841246544E-324 through
floating-point) 1.79769313486231570E+308 for positive values.

Integer System.Int32 4 bytes -2,147,483,648 through 2,147,483,647.

Long System.Int64 8 bytes -9,223,372,036,854,775,808 through


(long integer) 9,223,372,036,854,775,807.

Object System.Object (class) 4 bytes Any type can be stored in a variable of type Object.

Short System.Int16 2 bytes -32,768 through 32,767.

Single System.Single 4 bytes -3.4028235E+38 through -1.401298E-45 for negative


(single- values; 1.401298E-45 through 3.4028235E+38 for
precision positive values.
floating-point)

String System.String (class) Depends on 0 to approximately 2 billion Unicode characters.


(variable- implementing
length) platform

User- (inherits from Depends on Each member of the structure has a range
Defined System.ValueType) implementing determined by its data type and independent of the
Type platform ranges of the other members.
(structure)

Simplifying the above table:


1. Numerical Data Types
a. Whole Numbers
i. Byte
ii. Short
iii. Integer
iv. Decimal
v. Long
b. Real numbers
i. Single (float)
ii. Double
2. Character Data Types
a. Only One Character
i. Char
b. Many Character
i. String
3. Binary Data Types
a. Byte
4. Date
a. Contains Date and Time both at the same time.
5. Boolean
a. Contains the Yes or No information Yes is represented as a 1 and No as a 0

How to Declare a Variable in VB.NET


Dim <VariableName> As <DataType>
ex: Dim i As Integer
ex: Dim Age As Integer
ex: Dim TDate as Date
Ex: Dim I, J, K As Integer ' All three are Integer
variables.
Ex: Dim L, M As Long, X, Y As Single ' L and M are Long, X and
Y are Single.

Variable Scope or Lifetime

A local variable is one that is declared within a procedure. A module variable is declared at
module level, inside the module but not within any procedure internal to that module.
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 the variable is declared. Code located in a given
region can use the variables defined in that region without having to qualify their names.
When declaring scope, the following rules apply:

• The scope of a module variable is the entire namespace in which the module
is defined.
• The scope of a shared or instance variable is the structure or class in which it
is declared.
• The scope of a local variable is the procedure in which it is declared.
• However, if you declare a local variable within a block, its scope is that block
only. A block is a set of statements terminated by an End, Else, Loop, or Next
statement; for example, a For...Next or If...Then...Else...End If construction.

Declaring Accessibility

A variable's accessibility is determined by which keyword or keywords — Dim, Public,


Protected, Friend, Protected Friend, or Private — you use in the declaration statement.
You can declare a module, structure, class, or instance variable with any of these keywords.
Within a procedure, only the Dim keyword is allowed, and the accessibility is always
private.

Rules for Variable Name.

1.) Name must Begine with an AlphabetOnly

2.) Name must only contain AlphaNumeric Characters and or Undescore.


3.) Name must Be Meaningful, Ex: age, Rollnum, Price etc. Meaningless names as abc, s, cv
etc must be avoided.

4.) Name cannot be a VB.NET Keyword.

5.) Same Named Variables Cannot be used in Same Module.

6.) Variable Name must be limited to 32 Characters (Although more are permitted )

7.) VB.NET is not Case sensitive so variable "age", "Age","AGE" will be considered the
same which is not in the case of Visual C++ or C# where each variable will considered to be
a different variable.
asddadasasd

Das könnte Ihnen auch gefallen