Thursday, 20 March 2014

VB.Net Decision Making


Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false. Following is the general form of a typical decision making structure found in most of the programming languages:


Decision making statements in VB.Net
VB.Net provides following types of decision making statements. Click the following links to check their detail.

VB.NET Loop


VB.Net - Loops

There may be a situation when you need to execute a block of code several number of times. In general statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. Programming languages provide various control structures that allow for more complicated execution paths. A loop statement allows us to execute a statement or group of statements multiple times and following is the general form of a loop statement in most of the programming languages:

Loop Architecture

VB.Net provides following types of loop to handle looping requirements. Click the following links to check their detail.

Loop TypeDescription
Do LoopIt repeats the enclosed block of statements while a Boolean condition is True or until the condition becomes True. It could be terminated at any time with the Exit Do statement.
For...Next It repeats a group of statements a specified number of times and a loop index counts the number of loop iterations as the loop executes.
For Each...Next It repeats a group of statements for each element in a collection. This loop is used for accessing and manipulating all elements in an array or a VB.Net collection.
While... End WhileIt executes a series of statements as long as a given condition is True.
With... End WithIt is not exactly a looping construct. It executes a series of statements that repeatedly refers to a single object or structure.
Nested loopsYou can use one or more loop inside any another While, For or Do loop.

Loop Control Statements:

Loop control statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed.
VB.Net provides the following control statements. Click the following links to check their detail.
Control StatementDescription
Exit statementTerminates the loop or select case statement and transfers execution to the statement immediately following the loop or select case.
Continue statementCauses the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
GoTo statementTransfers control to the labeled statement. Though it is not advised to use GoTo statement in your program.

Wednesday, 19 March 2014

VB.Net Web Programming

A dynamic web application consists of either or both of the following two types of programs:
  • Server-side scripting - these are programs executed on a web server, written using server-side scripting languages like ASP (Active Server Pages) or JSP (Java Server Pages).
  • Client-side scripting - these are programs executed on the browser, written using scripting languages like JavaScript, VBScript etc.
ASP.Net is the .Net version of ASP, introduced by Microsoft, for creating dynamic web pages by using server-side scripts. ASP.Net applications are compiled codes, written using the extensible and reusable components or objects present in .Net framework. These codes can use the entire hierarchy of classes in .Net framework.
The ASP.Net application codes could be written in either of the following languages:
  • Visual Basic .Net
  • C#
  • Jscript
  • J#
In this chapter, we will give a very brief introduction to writing ASP.Net applications using VB.Net. For detailed discussion, please consult the ASP.Net Tutorial.

VB.Net XML Processing

The Extensible Markup Language (XML) is a markup language much like HTML or SGML. This is recommended by the World Wide Web Consortium and available as an open standard.
The System.Xml namespace in the .Net Framework contains classes for processing XML documents. Following are some of the commonly used classes in the System.Xml namespace.

VB.Net Send E-mail

VB.Net allows sending E-mails from your application. The System.Net.Mail namespace contains classes used for sending emails to a Simple Mail Transfer Protocol (SMTP) server for delivery.
The following table lists some of these commonly used classes:

S.NClassDescription
1AttachmentRepresents an attachment to an e-mail.
2AttachmentCollectionStores attachments to be sent as part of an e-mail message.
3MailAddressRepresents the address of an electronic mail sender or recipient.
4MailAddressCollectionStore e-mail addresses that are associated with an e-mail message.
5MailMessageRepresents an e-mail message that can be sent using the SmtpClient class.
6SmtpClientAllows applications to send e-mail by using the Simple Mail Transfer Protocol (SMTP).
7SmtpExceptionRepresents the exception that is thrown when the SmtpClient is not able to complete a Send or SendAsync operation.

VB.Net Database Access

Applications communicate with a database, firstly, to retrieve the data stored there and present it in a user-friendly way, and secondly, to update the database by inserting, modifying and deleting data.
Microsoft ActiveX Data Objects.Net (ADO.Net) is a model, a part of the .Net framework that is used by the .Net applications for retrieving, accessing and updating data.

ADO.Net Object Model

ADO.Net object model is nothing but the structured process flow through various components. The object model can be pictorially described as:

VB.Net Regular Expressions

A regular expression is a pattern that could be matched against an input text. The .Net framework provides a regular expression engine that allows such matching. A pattern consists of one or more character literals, operators, or constructs.

Constructs for Defining Regular Expressions

There are various categories of characters, operators, and constructs that lets you to define regular expressions. Click the follwoing links to find these constructs.

The Regex Class

The Regex class is used for representing a regular expression.
The Regex class has the following commonly used methods: