You may also come across instances in which you need to exit a loop prematurely.
In these cases, you would use either Exit, if your code is in VB, or the equivalent
(break) statement in C#, to terminate the loop:
Dim i As Integer
For i = 0 To 10
If (i = 5) Then
Response.Write("Oh no! Not the number 5!!")
for (i = 0; i <= 10; i++)
if (i == 5)
Response.Write("Oh no! Not the number 5!!");
In this case, as soon as our For loop hits the condition i = 5, it displays a
warning message using the Response.Write method (which will be familiar to
those with past ASP experience), and exits the loop so that no further passes
through the loop will be made.
Although we’ve only scratched the surface, VB and C# provide a great deal of
power and flexibility to web developers, and time spent learning the basics now
will more than pay off in the future.
Object Oriented Programming Concepts
VB and C# are modern programming languages that give you the tools to write
structured, extensible, and maintainable code. The code can be separated into
modules, each of which defines classes that can be imported and used in other
modules. Both languages are relatively simple to get started with, yet they offer
sophisticated features for writing complex, large-scale enterprise applications.
One of the reasons why these languages are so powerful is that they facilitate
object oriented programming (OOP). In this section, we’ll explain the funda-
Chapter 3: VB and C# Programming Basics