Академический Документы
Профессиональный Документы
Культура Документы
.NET DEFINED
Before getting deeply into the subject we will first know how
Businesses are related to Internet, what .NET means to them and
what exactly .NET is built upon. As per the product documentation
from a Business perspective, there are three phases of the Internet.
The First phase gets back to the early 1990's when Internet first
came into general use and which brought a big revolution for
Businesses. In the First phase of the Internet Businesses designed
and launched their Website's and focused on the number of hits to
know how many customers were visiting their site and interested in
their products, etc. The Second phase is what we are in right now
and in this phase Businesses are generating revenue through Online
Transactions. We are now moving into the Third phase of the
Internet where profit is the main priority. The focus here is to
Businesses effectively communicate with their customers and
partners who are geographically isolated, participate in Digital
Economy and deliver a wide range of services. How can that be
possible? The answer, with .NET.
WHATIS .NET ?
Many people reckon that it's Microsoft's way of
controlling the Internet, which is false. .NET is
Microsoft's strategy of software that provides
services to people any time, any place, on any
device. An accurate definition of .NET is, it's an
XML Web Services platform which allows us to
build rich .NET applications, which allows users to
interact with the Internet using wide range of
smart devices (tablet devices, pocket PC's, web
phones etc), which allows to build and integrate
Web Services and which comes with many rich set
of tools like Visual Studio to fully develop and
build those applications.
VB .NET IDE
Start Page
Menu Bar
Toolbars
New Project Dilogbox
Object Browser
The Toolbox
The Solution Explorer
Class View Window
Property Window
Dynamic Help Window
Component Tray
The Server Explorer
DATATYPES
DataType Size in Bytes
Byte
1
8-bit
Char
2 16-bit
Integer 4
32-bit
Double 8
64-bit
Long
8
64-bit
Short
2
16-bit
System.Byte
System.Char
System.Int32
System.Double
System.Int64
System.Int16
Single
4
32-bit
System.Single
String Varies Non-Numeric
Date
8
System.Date
Boolean 2 Non-Numeric
Object
4 Non-Numeric
Decimal 16 128-bit
System.Decimal
System.String
System.Boolean
System.Object
ACCESS SPECIFIERS
NAMESPACES
A namespace is a collection of different
classes. All VB applications are developed
using classes from the .NET System
namespace. The namespace with all the
built-in VB functionality is the System
namespace. All other namespaces are based
on this System namespace
CONTD
ASSEMBLIES
An assembly is the building block of a .NET
application.
It is a self describing collection of code,
resources, and metadata (data about data,
example, name, size, version of a file is
metadata about that file).
An Assembly is a complied and versioned
collection of code and metadata that forms
an atomic functional unit.
CONTD
Assemblies take the form of adynamic link
library (.dll) file or executable program file
(.exe)
Assemblies are made of two parts: manifest,
contains information about what is contained
within the assembly and modules internal
files of IL code which are ready to run
The assembly file is visible in the Solution
Explorer window of the project.
VARIABLES
Variables are used to store data. A variable has
a name to which we refer and the data type,
the type of data the variable holds. VB .NET
now needs variables to be declared before
using them. Variables are declared with the
Dim keyword. Dim stands for Dimension.
EXAMPLE OF VARIABLE
Dim a,b,c as Integer
'declaring three variables of type integer
a=10
b=20
c=a+b
Write("Sum of a and b is" & c)
End Sub
STATEMENTS
A statement is a complete instruction.
It can contain keywords, operators, variables, literals,
expressions and constants.
Each statement in Visual Basic should be either a
declaration statement or a executable statement.
A declaration statement is a statement that can create
a variable, constant, data type.
They are the one's we generally use to declare our
variables.
On the other hand, executable statements are the
statements that perform an action.
They execute a series of statements.
They can execute a function, method, loop, etc.
OPTION STATEMENT
CONT ...
EXPLICIT CONVERSIONS
When types cannot be implicitly converted you should convert them
explicitly. This conversion is also called as cast. Explicit conversions
are accomplished using CType function.
CType function for conversion If we are not sure of the name of a
particular conversion function then we can use the CType function.
The above example with a CType function looks like this:
Imports System.Console
Module Module1
Sub Main() Dim d As Double
d = 132.31223
Dim i As Integer i = CType(d, i)
'two arguments, type we are converting from, to type desired
WriteLine("Integer value is" & i)
End Sub
EXPLICIT CONVERSIONS
OPERATORS
Visual Basic comes with many built-in
operators that allow us to manipulate data.
An operator performs a function on one or
more operands. For example, we add two
variables with the "+" addition operator and
store the result in a third variable with the
"=" assignment operator like this: int x + int y
= int z. The two variables (x ,y) are called
operands. There are different types of
operators in Visual Basic and they are
described below in the order of their
precedence
ARITHMETICOPERATORS
CONCATENATIONOPERATORS
Concatenation operators join multiple strings
into a single string. There are two
concatenation operators, + and & as
summarized below:
Operator Use
+ String Concatenation
& String Concatenation
COMPARISONOPERATORS
A comparison operator compares operands and
returns a logical value based on whether the
comparison is true or not. The table below
summarizes them:
Operator Use
= Equality
<> Inequality
< Less than
> Greater than
>=Greater than or equal to
<=Less than or equal to
ARRAYS
Arrays are programming constructs that store data and allow us
to access them by numeric index or subscript. Arrays helps us
create shorter and simpler code in many situations. Arrays in
Visual Basic .NET inherit from the Array class in the System
namespace. All arrays in VB as zero based, meaning, the index
of the first element is zero and they are numbered
sequentially. You must specify the number of array elements
by indicating the upper bound of the array. The upper bound is
the numder that specifies the index of the last element of the
array. Arrays are declared using Dim, ReDim, Static, Private,
Public and Protected keywords. An array can have one
dimension (liinear arrays) or more than one (multidimensional
arrays). The dimensionality of an array refers to the number
of subscripts used to identify an individual element. In Visual
Basic we can specify up to 32 dimensions. Arrays do not have
fixed size in Visual Basic.
ARRAY DECLARATION
To declare a single-dimensional array variable
In your declaration, add one pair of parentheses after the
variable name, as in the following example:
Dim MySingleArray() As Integer
To declare a multidimensional array variable
In your declaration, add one pair of parentheses after the
variable name and place commas inside the parentheses to
separate the dimensions, as in the following example:
Dim My4DArray(,,,) As Short' Four-dimensional array.
To declare a jagged array variable
In your declaration, add as many pairs of parentheses after the
variable name as there are levels of nested arrays, as in the
following example:
Dim MyJaggedArray()()() As Byte' Array of arrays of Byte
arrays.
INITIALIZING ARRAYS
CONTROL STATEMENTS
The conditional statement IF ELSE , is use for examining the
conditions that we provided, and making decision based on
that contition. The conditional statement examining the
data using comparison operators as well as logical
operators
If [your condition here]
Your code here
Else
Your code Here
End If
If the contition is TRUE then the control goes to between IF
and Else block , that is the program will execute the code
between IF and ELSE statements.
If the contition is FLASE then the control goes to between
CONTD
If you want o check more than one condition at the same
time , you can use ElseIf .
IF - ELSE EXAMPLE
Just take a real-time example - When we want to analyze a mark lists
we have to apply some conditions for grading students depends on
the marks.
Following are the garding rule of the mark list:
1) If the marks is greater than 80 then the student get higher first class
2) If the marks less than 80 and greater than 60 then the student get
first class
3) If the marks less than 60 and greater than 40 then the student get
second class
4) The last condition is , if the marks less than 40 then the student
fail.
CONTD
1.
2.
3.
4.
5.
6.
7.
8.
9.
Line
Line
Line
Line
Line
Line
Line
Line
Line
1
2
3
4
5
6
7
8
9
:
:
:
:
:
:
:
:
:
LOOPING CONSTUCTS
Loops are a common programming technique.
Most applications are made up primarily of
loops. These are sentences in your code that
tell the program what to look for and what to
do. Writing loops in VB.NET is a matter of
understanding what you need from the
program and what type of loop works best.
WHILE LOOP
While loop keeps executing until the condition
against which it tests remain true. The
syntax of while loop looks like this:
While condition
[statements]
End While
Do Loop
DO LOOP
The Do loop can be used to execute a fixed block of
statements indefinite number of times. The Do loop
keeps executing it's statements while or until the
condition is true. Two keywords, while and until can
be used with the do loop. The Do loop also supports
an Exit Do statement which makes the loop to exit at
any moment. The syntax of Do loop looks like this:
Do[{while | Until} condition]
[statements]
[Exit Do]
[statements]
Loop
EXAMPLE ON DO LOOP
Module Module1
Sub Main()
Dim str As String
Do Until str = "Cool"
System.Console.WriteLine("What to do?")
str = System.Console.ReadLine()
Loop
End Sub
End Module
BUTTON CONTROL
CONT
LABEL
TEXTBOX CONTROL
TEXTBOX CONTROL
Appearance section
TextAlign: Allows to align the text from three
possible options. The default value is left and
you can set the alignment of text to right or
center.
Scrollbars: Allows to add a scrollbar to a Textbox.
Very useful when the TextBox is multiline.
You have four options with this property. Options
are None, Horizontal, Vertical and Both.
Depending on the size of the TextBox anyone of
those can be used.
CHECKBOX
NOTABLE PROPERTIES
Important
CHECKBOX
CHECKBOX
CHECKBOX
COMBOBOX
CONT
CONT
LISTBOX
CONT
CONT..
Private SubListBox1_SelectedIndexChanged
(ByVal sender As System.Object,_ ByVal e As
System.EventArgs) Handles
ListBox1.SelectedIndexChanged
TextBox1.Text = ListBox1.SelectedItem
'using the selected item property
End Sub When you run the code and click an
item in the
Private SubListBox1_SelectedIndexChanged
(ByVal sender As System.Object,_ ByVal e As
System.EventArgs) Handles
ListBox1.SelectedIndexChanged
TextBox1.Text = ListBox1.SelectedItem
'using the selected item property
End Sub When you run the code and click
an item in the
EXAMPLE-CHECKBOX AND
OPTION BUTTON
Private
Else
If
EXAMPLE-CALCULATOR
MouseDown: This event happens when the mouse pointer is over the
form/control and is
pressed
MouseEnter: This event happens when the mouse pointer enters the
form/control
MouseUp: This event happens when the mouse pointer is over the
form/control and the
MouseL eave: This event happens when the mouse pointer leaves the
form/control
MouseMove: This event happens when the mouse pointer is moved over
the form/control
MouseW heel: This event happens when the mouse wheel moves while the
form/control has
Visual Basic .NET comes with built-in dialog boxes which allow us to create
our own File Open, File Save, Font, Color dialogs much like
what we see in all other windows applications.
To make a dialog box visible at run time we use the dialog box's ShowDialog
method.
The Dialog Boxes which come with Visual Basic .NET are:
OpenFileDialog
SaveFileDialog
FontDialog
ColorDialog
PrintDialog
PrintPreviewDialog and
PageSetupDialog.
We will be working with OpenFile, SaveFile, Font and Color Dialog's in this
section. The return values of all the above said dialog boxes which will
determine which selection a user makes are: Abort, Cancel,
Ignore, No, None, OK, Return, Retry and Yes.
FONT DIALOG
COLORDIALOGS