Escolar Documentos
Profissional Documentos
Cultura Documentos
Chapter 3
VB .NET Programming
Fundamentals
Introducing VB .NET
Introducing VB .NET
VB .NET:
Debugging chores
Maintenance chores
VB .NET identifiers:
Can be of any length
Can include any letter or number, but no spaces
Must begin with a letter of the alphabet
Object-Oriented Application Development Using
VB .NET
10
Keyword Dim
Name to be used for identifier
Keyword As
Data type
Example:
11
12
13
14
15
Using Constants
16
Reference variable
Dim x, y, z As Integer
17
18
19
Evaluates an expression
Executes one or more statements if expression is
true
Can execute another statement or group of
statements if expression is false
21
22
Writing If Statements
20
23
24
Writing If Statements
Writing If Statements
VB .NET If statement has two forms: Simple If and
If-Else
Simple If
Evaluates an expression
Executes one or more statements if expression is
true
25
Writing If Statements
26
Writing If Statements
If-Else
Evaluates an expression
Executes one or more statements if expression is
true
Executes a second statement or set of statements
if expression is false
27
Writing If Statements
28
29
30
Writing Loops
Do While
Do Until
For Next
31
33
A Do Until loop:
' do until loop
i = 1 ' re-initialize loop counter variable
Do Until i > 3
Console.WriteLine("do until loop: i = " & i)
i += 1
Loop
34
32
35
36
37
38
Nested loop:
Example:
' for next loop
For i = 1 To 3 Step 1
Console.WriteLine("for next loop: i = " & i)
Next
Object-Oriented Application Development Using
VB .NET
39
40
41
42
testScores(0) = 75
testScores(1) = 80
testScores(2) = 70
testScores(3) = 85
testScores(4) = 90
43
44
45
46
47
48
Summary
Summary
50