Professional Documents
Culture Documents
NET Framework
Before .NET
• Windows GUI development: Win32 API,
MFC, Visual Basic
• Web development: ASP
• Java – “Write once, run anywhere.”
• Embrace and extend: Visual J++
.Net Framework
• A set of approximately 3500 classes.
Visual Studio.NET
ASP.NET: Web Services Windows
Windows
and Web Forms Forms
Forms
compile execute
Hello.java Hello.class JVM
compile execute
Hello.vb Hello.exe CLR
• Primary Parts:
.Net Framework
Common Language Runtime (CLR)
• RTM:
– 2002 (v1.0)
– 2003 (v1.1)
– 2005 (v2.0)
.Net Programming Languages
1. Visual Basic.Net 13. RPG
2. C# 14. Component Pascal
3. APL 15. Mercury
4. Fortran 16. Scheme
5. Pascal 17. Curriculum
6. C++ 18. Mondrian
7. Haskell 19. SmallTalk
8. Perl 20. Eiffel
9. Java Language 21. Oberon
10.Python 22. Standard ML
11.COBOL 23. Forth
12.Microsoft JScript 24. Oz
Advantages of .Net
• Write once, run everywhere
• Coding Reduction
– Controls
– Template projects
– IIS/Cassini support
• Ease of Deployment
• Security Features
– Evidence-based security
– Code access security
– The verification process
– Role-based security
– Cryptography
– Application domains
Introduction to VB.Net
• VB .Net is developed by Microsoft
• It is Visual Basic for .Net Platform
• Ancestor of VB .Net is BASIC
• In 1991, Microsoft added visual components to
BASIC and created Visual Basic
• After the development of .Net, VB was added
with more set of controls and components and
thus evolved a new language VB .Net
Features of VB .Net
• Object Oriented Language
• We can drag controls from the tool bar and
drop them on the form and write code for
the controls
• Runs on the CLR (Common Language
Runtime)
• Release of unused objects taken care by
the CLR
VB.NET Language Essential
----For Non-VB Programmers
• Projects Types
– Three most commonly used:
• Windows Forms
• Web Forms
• Console Applications
Collapsed Regions
Tabs
Method List
Class
List
Collapsed
Region
Collapsed
Procedure
Creating VB .Net Project in VS 2005
• Data types
– Integer, string, single, double, boolean, char
• Operators
– Arithmetic (+,-,*,/,\,Mod)
– Logical (Or, And)
– Relational (=,<>,<,<=,>,>=)
If Else
If (Condition)
Then
Statements executed if condition is true
Else
Statements executed if condition is false
EndIf
Eg
For I = 1 To 10 Step 2
Console.WriteLine(I)
Next
Here the values printed will be 1,3,5,7,9
Loop Statement: For
• Syntax:
For index=start To end [Step step]
[statements]
[Exit For]
[statements]
Next [index]
• E.g.
Module Module1
Sub Main()
Dim loopIndex As Integer
For loopIndex=0 to 3
System.Console.WriteLine(“Hello!”)
Next loopIndex
End Sub
End Module
Do While Loop
1. Do While(a<>0)
Console.Writeline(a)
a=a–1
Loop
2. Do
Console.Writeline(a)
a=a–1
Loop While(a<>0)
Loop Statement: Do
• Syntax:
Do [While|Until] condition]
[statements]
[Exit Do]
[statements]
Loop
• E.g.
Module Module1
Sub Main()
Dim strInput As String
Do Until Ucase(strInput)=“Stop”
System.Console.WriteLine(“What should I do?”)
strInput=System.Console.ReadLine()
Loop
End Sub
End Module
Loop Statement: For Each…
Next
• Syntax:
For Each element In group
[statements]
[Exit For]
[statements]
Next element
• E.g.
Sub Main()
Dim intArray(2), intItem As Integer
intArray(0)=0
intArray(1)=1
intArray(2)=2
For Each intItem In intArray
System.Console.WriteLine(intArray)
Next intItem
End Sub
Do Until Loop
1. Do Until(a=0)
Console.Writeline(a)
a=a–1
Loop
2. Do
Console.Writeline(a)
a=a–1
Loop Until(a=0)
Changes in VB Language
(cont.)
• When calling procedures, must use
parentheses.
• Parameters are by default passed by value,
instead of by reference.
• Supports constructors and destructors for use
when initializing an object of a class.
• If…Then statements are now short-circuited.
Loop Statement: While
• Syntax:
While condition
[statements]
End While
• E.g.
Sub CheckWhile()
Dim intCounter As Integer =0
Dim intNumber As Integer =10
While intNumer>6
intNumber-=1
intCounter+=1
End While
MsgBox(“The loop ran “ & intCounter & “ times.”)
End Sub
Like a Loop: With
• Syntax:
With object
[statements]
End With
• E.g.
With TextBox1
,Height = 1000
.Width = 3000
.Text = “Welcome, World!”
End With
Like With: Enumerations
• E.g.
Module Module
Enum Days
Sunday=1
Monday=2
Tuesday=3
Wednesday=4
End Enum
Sub Main()
System.Console.WriteLine(“Monday is day “ & Days.Monday)
End Sub
End Module