Application of .NET Technology Unit 06 Introduction to Programming with Visual Basic.NET Notes Set 02

Computer Science Study Guide: Application of .NET Technology Unit 06 Introduction to Programming with Visual Basic.NET Notes Set 02

Access comprehensive study materials and useful resources for .NET Technology using the Application of .NET Technology Unit 06 Introduction to Programming with Visual Basic.NET Notes Set 02. Designed to align with the 2026-27 academic guidelines, these advanced resources help Computer Science students reinforce core concepts beyond standard textbooks.

Download .NET Technology Study Material PDF

Access the complete useful resource PDF for Computer Science below. Regular practice with these targeted academic notes builds familiarity with complex topics and helps secure higher marks in final school evaluations.

Here the unit covers the statement types in VB.Net, from declaration and executable statements to compiler directives such as #Const and #Region. It then explains decision making with If and Select Case, the looping constructs, the Exit, Continue and GoTo statements, the String class and seven small Windows application exercises.

Statements

A statement is a complete instruction in Visual Basic programs. It may contain keywords, operators, variables, literal values, constants and expressions. Statements could be categorized as:

1. Declaration statements
2. Executable statements

Declaration statements

These are the statements where you name a variable, constant, or procedure, and can also specify a data type. The declaration statements are used to name and define procedures, variables, properties, arrays, and constants. When you declare a programming element, you can also define its data type, access level, and scope.

The programming elements you may declare include variables, constants, enumerations, classes, structures, modules, interfaces, procedures, procedure parameters, function returns, external procedure references, operators, properties, events, and delegates.

Executable statements

These are the statements, which initiate actions. These statements can call a method or function, loop or branch through blocks of code or assign values or expression to a variable or constant. In the last case, it is called an Assignment statement.

Statements and description

Dim Statement

Declares and allocates storage space for one or more variables. Example:

Dim number As Integer
Dim quantity As Integer = 100
Dim message As String = "Hello!"

Const Statement

Declares and defines one or more constants. Example:

Const maximum As Long = 1000
Const naturalLogBase As Object = CDec(2.7182818284)

Enum statement

Declares an enumeration and defines the values of its members. Example:

Enum CoffeeMugSize
    Jumbo
    ExtraLarge
    Large
    Medium
    Small
End Enum

Class Statement

Declares the name of a class and introduces the definition of the variables, properties, events, and procedures that the class comprises. Example:

Class Box
    Public length As Double
    Public breadth As Double
    Public height As Double
End Class

Structure Statement

Declares the name of a structure and introduces the definition of the variables, properties, events, and procedures that the structure comprises. Example:

Structure Box
    Public length As Double
    Public breadth As Double
    Public height As Double
End Structure

Module statement

Declares the name of a module and introduces the definition of the variables, properties, events, and procedures that the module comprises. Example:

Public Module myModule
    Sub Main()
        Dim user As String = InputBox("What is your name?")
        MsgBox("User name is " & user)
    End Sub
End Module

Interface Statement

Declares the name of an interface and introduces the definitions of the members that the interface comprises. Example:

Public Interface MyInterface
    Sub doSomething()
End Interface

Function Statement

Declares the name, parameters, and code that define a Function procedure. Example:

Function myFunction(ByVal n As Integer) As Double
    Return 5.87 * n
End Function

Sub statement

Declares the name, parameters, and code that define a Sub procedure. Example:

Sub mySub(ByVal s As String)
    Return
End Sub

Declare Statement

Declares a reference to a procedure implemented in an external file. Example:

Declare Function getUserName Lib "advapi32.dll" _
    Alias "GetUserNameA" _
    (ByVal lpBuffer As String, ByRef nSize As Integer) As Integer

Operator Statement

Declares the operator symbol, operands, and code that define an operator procedure on a class or structure. Example:

Public Shared Operator +(ByVal x As obj, ByVal y As obj) As obj
    Dim r As New obj
    ' implementation code for r = x + y
    Return r
End Operator

Property Statement

Declares the name of a property, and the property procedures used to store and retrieve the value of the property. Example:

ReadOnly Property quote() As String
    Get
        Return quoteString
    End Get
End Property

Event Statement

Declares a user-defined event. Example:

Public Event Finished()

Delegate Statement

Used to declare a delegate. Example:

Delegate Function MathOperator( _
    ByVal x As Double, _
    ByVal y As Double _
) As Double

Executable Statements

An executable statement performs an action. Statements calling a procedure, branching to another place in the code, looping through several statements, or evaluating an expression are executable statements. An assignment statement is a special case of an executable statement. The following example demonstrates an executable statement:

Module decisions
    Sub Main()
        'local variable definition
        Dim a As Integer = 10
        ' check the boolean condition using if statement
        If (a < 20) Then
            ' if condition is true then print the following
            Console.WriteLine("a is less than 20")
        End If
        Console.WriteLine("value of a is : {0}", a)
        Console.ReadLine()
    End Sub
End Module

When the above code is compiled and executed, it produces the following result:

a is less than 20
value of a is : 10

Directives

The VB.Net compiler directives give instructions to the compiler to preprocess the information before actual compilation starts. All these directives begin with #, and only white-space characters may appear before a directive on a line. These directives are not statements.

#Const constname = expression

VB.Net compiler does not have a separate preprocessor; however, the directives are processed as if there was one. In VB.Net, the compiler directives are used to help in conditional compilation. Unlike C and C++ directives, they are not used to create macros.

Compiler Directives in VB.Net

VB.Net provides the following set of compiler directives:

1. The #Const Directive,
2. The #ExternalSource Directive,
3. The #If...Then...#Else Directives,
4. The #Region Directive.

#Const Directives

This directive defines conditional compiler constants. Syntax for this directive is:

#Const constname = expression

1. constname: specifies the name of the constant. Required.
2. expression: it is either a literal, or other conditional compiler constant, or a combination including any or all arithmetic or logical operators except Is.

For example:

#Const state = "WEST BENGAL"

Example:

Module mydirectives
#Const age = True
    Sub Main()
#If age Then
        Console.WriteLine("You are welcome to the Robotics Club")
#End If
        Console.ReadKey()
    End Sub
End Module

When the above code is compiled and executed, it produces the following result:

You are welcome to the Robotics Club

#ExternalSource Directives

This directive is used for indicating a mapping between specific lines of source code and text external to the source. It is used only by the compiler and the debugger has no effect on code compilation. This directive allows including external code from an external code file into a source code file. Syntax for this directive is:

#ExternalSource( StringLiteral , IntLiteral )
    [ LogicalLine ]
#End ExternalSource

The parameters of #ExternalSource directive are the path of external file, line number of the first line, and the line where the error occurred. The following code demonstrates a hypothetical use of the directive:

Module mydirectives
    Public Class ExternalSourceTester
        Sub TestExternalSource()
#ExternalSource("c:\vbprogs\directives.vb", 5)
            Console.WriteLine("This is External Code. ")
#End ExternalSource
        End Sub
    End Class
    Sub Main()
        Dim t As New ExternalSourceTester()
        t.TestExternalSource()
        Console.WriteLine("In Main.")
        Console.ReadKey()
    End Sub
End Module

The #If...Then...#Else Directives

This directive conditionally compiles selected blocks of Visual Basic code. Syntax for this directive is:

#If expression Then
    statements
[ #ElseIf expression Then
    [ statements ]
[ #ElseIf expression Then
    [ statements ] ]
[ #Else
    [ statements ] ]
#End If

The following code demonstrates a hypothetical use of the directive:

#Const TargetOS = "Linux"
#If TargetOS = "Windows 7" Then
    ' Windows 7 specific code
#ElseIf TargetOS = "WinXP" Then
    ' Windows XP specific code
#Else
    ' Code for other OS
#End If

The #Region Directives

This directive helps in collapsing and hiding sections of code in Visual Basic files. Syntax for this directive is:

#Region "identifier_string"
#End Region

Example:

#Region "StatsFunctions"
    ' Insert code for the Statistical functions here.
#End Region

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. VB.Net provides the following types of decision making statements:

1. If ... Then statement.
2. If...Then...Else statement.
3. Nested If statements.
4. Select Case statement.
5. Nested Select Case statements.

If ... Then statement

An If...Then statement consists of a Boolean expression followed by one or more statements. It is the simplest form of control statement, frequently used in decision making and changing the control flow of the program execution.

If condition Then
    [Statement(s)]
End If

Where, condition is a Boolean or relational condition and Statement(s) is a simple or compound statement. An example of an If statement is:

If (a <= 20) Then
    c = c + 1
End If

If the condition evaluates to true, then the block of code inside the If statement will be executed. If condition evaluates to false, then the first set of code after the end of the If statement (after the closing End If) will be executed.

If...Then...Else statement

An If...Then statement can be followed by an optional Else statement, which executes when the Boolean expression is false. The syntax of an If...Then...Else statement in VB.Net is as follows:

If (boolean_expression) Then
    'statement(s) will execute if the Boolean expression is true
Else
    'statement(s) will execute if the Boolean expression is false
End If

Nested If statements

You can use one If or Else if statement inside another If or Else if statement(s). It is always legal in VB.Net to nest If-Then-Else statements, which means you can use one If or ElseIf statement inside another If ElseIf statement(s). The syntax for a nested If statement is as follows:

If (boolean_expression 1) Then
    'Executes when the boolean expression 1 is true
    If (boolean_expression 2) Then
        'Executes when the boolean expression 2 is true
    End If
End If

Select Case statement

A Select Case statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each select case. The syntax for a Select Case statement in VB.Net is as follows:

Select [ Case ] expression
    [ Case expressionlist
        [ statements ] ]
    [ Case Else
        [ elsestatements ] ]
End Select

Nested Select Case statements

You can use one select case statement inside another select case statement(s). It is possible to have a select statement as part of the statement sequence of an outer select statement. Even if the case constants of the inner and outer select contain common values, no conflicts will arise.

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. VB.Net provides the following types of loops to handle looping requirements:

1. Do Loop,
2. For...Next,
3. For Each...Next,
4. While... End While,
5. With... End With,
6. Nested loops.

Do Loop

It 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. The syntax for this loop construct is:

Do { While | Until } condition
    [ statements ]
    [ Continue Do ]
    [ statements ]
    [ Exit Do ]
    [ statements ]
Loop
-or-
Do
    [ statements ]
    [ Continue Do ]
    [ statements ]
    [ Exit Do ]
    [ statements ]
Loop { While | Until } condition

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. The syntax for this loop construct is:

For counter [ As datatype ] = start To end [ Step step ]
    [ statements ]
    [ Continue For ]
    [ statements ]
    [ Exit For ]
    [ statements ]
Next [ counter ]

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. The syntax for this loop construct is:

For Each element [ As datatype ] In group
    [ statements ]
    [ Continue For ]
    [ statements ]
    [ Exit For ]
    [ statements ]
Next [ element ]

While... End While

It executes a series of statements as long as a given condition is True. The syntax for this loop construct is:

While condition
    [ statements ]
    [ Continue While ]
    [ statements ]
    [ Exit While ]
    [ statements ]
End While

Here, statement(s) may be a single statement or a block of statements. The condition may be any expression, and true is logical true. The loop iterates while the condition is true.

With... End With

The syntax for this loop construct is:

With object
    [ statements ]
End With

It is not exactly a looping construct. It executes a series of statements that repeatedly refers to a single object or structure.

Nested loops

You can use one or more loops inside any another While, For or Do loop.

1. Nested For loop,
2. Nested While loop,
3. Nested Do...While 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:

1. Exit statement,
2. Continue statement,
3. GoTo statement.

Exit statement

The Exit statement transfers the control from a procedure or block immediately to the statement following the procedure call or the block definition. It terminates the loop, procedure, try block or the select block from where it is called. If you are using nested loops (i.e., one loop inside another loop), the Exit statement will stop the execution of the innermost loop and start executing the next line of code after the block. The syntax for the Exit statement is:

Exit { Do | For | Function | Property | Select | Sub | Try | While }

It terminates the loop or select case statement and transfers execution to the statement immediately following the loop or select case.

Continue statement

The Continue statement causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. It works somewhat like the Exit statement. Instead of forcing termination, it forces the next iteration of the loop to take place, skipping any code in between. For the For...Next loop, Continue statement causes the conditional test and increment portions of the loop to execute. For the While and Do...While loops, continue statement causes the program control to pass to the conditional tests. The syntax for a Continue statement is as follows:

Continue { Do | For | While }

GoTo statement

The GoTo statement transfers control unconditionally to a specified line in a procedure. The syntax for the GoTo statement is:

GoTo label

It transfers control to the labeled statement. Though it is not advised to use GoTo statement in your program.

Strings - Creating a String Object

In VB.Net, you can use strings as array of characters, however, more common practice is to use the String keyword to declare a string variable. The string keyword is an alias for the System.String class.

You can create string object using one of the following methods:

1. By assigning a string literal to a String variable.
2. By using a String class constructor.
3. By using the string concatenation operator (+).
4. By retrieving a property or calling a method that returns a string.
5. By calling a formatting method to convert a value or object to its string representation.

Properties of the String Class

The String class has the following two properties:

PropertyDescription
CharsGets the Char object at a specified position in the current String object.
LengthGets the number of characters in the current String object.

Methods of the String Class

The String class has numerous methods that help you in working with the string objects.

MethodDescription
Public Shared Function Compare ( strA As String, strB As String ) As IntegerCompares two specified string objects and returns an integer that indicates their relative position in the sort order.
Public Shared Function Compare ( strA As String, strB As String, ignoreCase As Boolean ) As IntegerCompares two specified string objects and returns an integer that indicates their relative position in the sort order. However, it ignores case if the Boolean parameter is true.
Public Shared Function Concat ( str0 As String, str1 As String ) As StringConcatenates two string objects.
Public Shared Function Concat ( str0 As String, str1 As String, str2 As String ) As StringConcatenates three string objects.
Public Shared Function Concat ( str0 As String, str1 As String, str2 As String, str3 As String ) As StringConcatenates four string objects.
Public Function Contains ( value As String ) As BooleanReturns a value indicating whether the specified string object occurs within this string.
Public Shared Function Copy ( str As String ) As StringCreates a new String object with the same value as the specified string.
Public Sub CopyTo ( sourceIndex As Integer, destination As Char(), destinationIndex As Integer, count As Integer )Copies a specified number of characters from a specified position of the string object to a specified position in an array of Unicode characters.
Public Function EndsWith ( value As String ) As BooleanDetermines whether the end of the string object matches the specified string.
Public Function Equals ( value As String ) As BooleanDetermines whether the current string object and the specified string object have the same value.
Public Shared Function Equals ( a As String, b As String ) As BooleanDetermines whether two specified string objects have the same value.
Public Shared Function Format ( format As String, arg0 As Object ) As StringReplaces one or more format items in a specified string with the string representation of a specified object.
Public Function IndexOf ( value As Char ) As IntegerReturns the zero-based index of the first occurrence of the specified Unicode character in the current string.
Public Function IndexOf ( value As String ) As IntegerReturns the zero-based index of the first occurrence of the specified string in this instance.
Public Function IndexOf ( value As Char, startIndex As Integer ) As IntegerReturns the zero-based index of the first occurrence of the specified Unicode character in this string, starting search at the specified character position.
Public Function IndexOf ( value As String, startIndex As Integer ) As IntegerReturns the zero-based index of the first occurrence of the specified string in this instance, starting search at the specified character position.
Public Function IndexOfAny ( anyOf As Char() ) As IntegerReturns the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters.
Public Function IndexOfAny ( anyOf As Char(), startIndex As Integer ) As IntegerReturns the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters, starting search at the specified character position.
Public Function Insert ( startIndex As Integer, value As String ) As StringReturns a new string in which a specified string is inserted at a specified index position in the current string object.
Public Shared Function IsNullOrEmpty ( value As String ) As BooleanIndicates whether the specified string is null or an Empty string.
Public Shared Function Join ( separator As String, ParamArray value As String() ) As StringConcatenates all the elements of a string array, using the specified separator between each element.
Public Shared Function Join ( separator As String, value As String(), startIndex As Integer, count As Integer ) As StringConcatenates the specified elements of a string array, using the specified separator between each element.
Public Function LastIndexOf ( value As Char ) As IntegerReturns the zero-based index position of the last occurrence of the specified Unicode character within the current string object.
Public Function LastIndexOf ( value As String ) As IntegerReturns the zero-based index position of the last occurrence of a specified string within the current string object.
Public Function Remove ( startIndex As Integer ) As StringRemoves all the characters in the current instance, beginning at a specified position and continuing through the last position, and returns the string.
Public Function Remove ( startIndex As Integer, count As Integer ) As StringRemoves the specified number of characters in the current string beginning at a specified position and returns the string.
Public Function Replace ( oldChar As Char, newChar As Char ) As StringReplaces all occurrences of a specified Unicode character in the current string object with the specified Unicode character and returns the new string.
Public Function Replace ( oldValue As String, newValue As String ) As StringReplaces all occurrences of a specified string in the current string object with the specified string and returns the new string.
Public Function Split ( ParamArray separator As Char() ) As String()Returns a string array that contains the substrings in the current string object, delimited by elements of a specified Unicode character array.
Public Function Split ( separator As Char(), count As Integer ) As String()Returns a string array that contains the substrings in the current string object, delimited by elements of a specified Unicode character array. The int parameter specifies the maximum number of substrings to return.
Public Function StartsWith ( value As String ) As BooleanDetermines whether the beginning of this string instance matches the specified string.
Public Function ToCharArray ( startIndex As Integer, length As Integer ) As Char()Returns a Unicode character array with all the characters in the current string object, starting from the specified index and up to the specified length.
Public Function ToCharArray As Char()Returns a Unicode character array with all the characters in the current string object.
Public Function ToLower As StringReturns a copy of this string converted to lowercase.
Public Function ToUpper As StringReturns a copy of this string converted to uppercase.
Public Function Trim As StringRemoves all leading and trailing white-space characters from the current String object.

Some Simple Applications

Simple Application 1

VB.Net program to accept any character from keyboard and display whether it is vowel or not.

1. Click Start, Programs, Microsoft Visual Studio 2008, Microsoft Visual Studio 2008.
2. Select File, New, Project, Windows Application.
3. Place the label, textbox and button in the window.
4. Write the code in click event of btnresult.
5. Run the application by pressing F5 key or by clicking debug button.

Simple Application 2

VB .NET program to accept a string and convert the case of the characters.

1. Click Start, Programs, Microsoft Visual Studio 2008, Microsoft Visual Studio 2008.
2. Select File, New, Project, Windows application.
3. Open the Windows application.
4. Place a label and text as enter the string.
5. Place two textboxes, one is used to enter the string, other used to display the result.
6. Then place two buttons, one is used to display result and other used to clear the textboxes.
7. Then write the code in click event of button1 and button2.
8. Run the application by F5 key or pressing debug button.

Simple Application 3

Develop a menu based VB .NET application to implement a text editor with cut, copy, paste, save and close operations.

1. Click Start, Programs, Microsoft Visual Studio 2008, Microsoft Visual Studio 2008.
2. Select File, New, Project, Windows application.
3. Open the Windows application.
4. Place the MenuStrip in the form from tool box.
5. Main menu is constructed with number of sub menus named as open, close, save, cut, copy, paste, undo, redo, color, font etc.
6. Drag and place a RichTextBox in the form.
7. Insert the source code for appropriate menu items and finally run the application.

Simple Application 4

Program to implement the calculator with memory and recall operations.

1. Click Start, Programs, Microsoft Visual Studio 2008, Microsoft Visual Studio 2008.
2. Select File, New, Project, Windows application.
3. Open the windows application form.
4. Place fifteen buttons and named as 0 to 9 and operators +, -, *, /, =.
5. Add another three buttons named as memory, recall, cancel.
6. Type the code in appropriate events.
7. Run the application by F5 key or pressing debug button.

Simple Application 5

Develop a form in VB .NET to pick a date from calendar control and display the day, month, year in separate textboxes.

1. Click Start, Programs, Microsoft Visual Studio 2008, Microsoft Visual Studio 2008.
2. Select File, New, Project, Windows application.
3. Open the windows application form.
4. Place a DateTimePicker to select the date.
5. Place four label and textboxes named as day, date, month, and year.
6. Edit the code in form load event and value changed event of DateTimePicker.
7. Run the application by pressing F5 key.

Simple Application 6

Develop a VB .NET application to perform timer based quiz of 10 questions.

1. Click Start, Programs, Microsoft Visual Studio 2008, Microsoft Visual Studio 2008.
2. Select File, New, Project, Windows application.
3. Open the windows application form.
4. Place a TextBox and named as txtquestion.
5. Place a GroupBox and enter text as Answer.
6. Within the GroupBox place three RadioButton.
7. Place a Button named as Result.
8. Then place a Timer and set interval property of timer as 3000.
9. Insert the code in Form_Load, btnresult, Timer1_Tick and RadioButton_CheckedChanged event.
10. Run the application by pressing F5 key.

Simple Application 7

Develop a VB .NET application using the File and Directory controls to implement a common dialog box.

1. Click Start, Programs, Microsoft Visual Studio 2008, Microsoft Visual Studio 2008.
2. Select File, New, Project, Windows application.
3. Open the Windows Application form.
4. Place FolderBrowserDialog and OpenFileDialog from ToolBox.
5. Place a GroupBox and enter Text as Select the Option.
6. Within the GroupBox place two RadioButton and enter Text as Folder Open, File Open.
7. Place a Button named as OK.
8. Place two Label and TextBox from the ToolBox.
9. Insert the code in click event of btn_ok.
10. Run the application by pressing F5 key.

CBSE Computer Science Study Material: .NET Technology

Essential Notes for Computer Science

Access comprehensive study material for .NET Technology, including revision notes, concept maps, and high-probability questions. These resources are designed in alignment with the latest 2026 CBSE syllabus for Computer Science to support effective exam preparation.

Verified Solutions for Computer Science

Each resource draws directly from authorized textbooks to maintain academic accuracy. Evaluating solved examples allows students to master the formal presentation and answer-writing standards expected in upcoming school exams.

Enhance Accuracy with Online Tests

Wrap up your chapter revision by testing your knowledge against standard objective question formats. Explore our full library of free, up-to-date sample papers and online assessments to secure top grades in your CBSE examinations.

FAQs

Where can I find the most advanced study material for [current-page:node:field_board] [current-page:node:field_class] Computer Science for 2026-27?

The latest 2026-27 advanced study resources for Computer Science are available for free on StudiesToday.com which includes NCERT Exemplars, high-order thinking skills (HOTS) questions, and deep-dive concept summaries.

What does the 2026-27 Computer Science study package for [current-page:node:field_class] include?

Our exhaustive Computer Science package includes chapter wise revision notes, solved practice sheets, important formulas and Concept Maps to help in better understanding of all topics.

Is this study material enough for both [current-page:node:field_board] exams and competitive tests?

Yes. For , our resources have been developed to help you get better marks in school exams and also build fundamental strength needed for entrance tests including Competency Based learning.

How should [current-page:node:field_class] students use this Computer Science material for maximum marks?

in , students should use Active Recall method, read the concept summary, then solve the Important Questions section without looking at the answers and then check your answers.

Can I download [current-page:node:field_class] Computer Science study notes in PDF for offline use?

All Computer Science study materials are provided in mobile-friendly PDF. You can download and save them on your device.

Are the [current-page:node:field_class] Computer Science resources updated for the latest NEP guidelines?

Yes, our team has ensured that all Computer Science materials for are strictly aligned with the National Education Policy (NEP) 2020 and the latest 2026-27 syllabus.