4th Sem VB NET 2022
4th Sem VB NET 2022
4th Sem VB NET 2022
KORAMANGALA, BENGALURU
Course:BCA403T Subject: VISUAL PROGRAMMING.NET
SECTION-A
Two marks questions
1. What is class library with reference to .NET framework?
The Framework class library (FCL) is a comprehensive collection of reusable
types including classes, interfaces and data types included in the . NET
Framework to provide access to system functionality. The . NET FCL forms the
base on which applications, controls and components are built in . NET.
Class View is shown as part of Solution Explorer and as a separate window. Class
View displays the elements of an application. The upper pane displays
namespaces, types, interfaces, enumerations, and classes, and the lower pane
displays the members that belong to the type selected in the upper pane.
8. What is solution explorer?
Server Explorer allows you to graphically create databases, tables, views, and
stored procedures completely from within Visual Studio . NET. You can also edit
and delete existing database objects.
10. What is task list in .net framework?
Task List is nothing but an integrated to-do list within the Visual Studio
framework.
11. What is output window?
The Output window displays status messages for various features in the integrated
development environment (IDE).
12. What is command window in .net framework?
SECTION B
Ten marks questions
13. What do you mean by IDE of VB.Net. Explain the various features of .Net.
c. Multi-language support:-
NET provides multi- language support by managing the compilers that are used to
convert the source to intermediate language (IL) and from IL to native code, and
it enforces program safety and security.
d. Tool Support
The CLR works hand-in-hand with tools like visual studio, compilers, debuggers,
and profilers to make the developer's job much simpler.
e. Security
The CLR manages system security through user and code identity coupled with
permission checks. The identity of the code can be known and permission for the
use of resources granted accordingly. This type of security is a major feature of
.NET. The .NET framework also provides support for role-based security using
Windows NT accounts and groups.
The .NET CLR provides efficient and automatic resource management such as
memory, screen space, network connections, database, etc. CLR invokes various
built-in functions of .NET framework to allocate and de-allocate the memory of
.NET objects.
The .NET IDE (integrated development environment) provides an easy and rich
debugging support. Once an exception occurs at run time, the program stops and
the IDE marks the line which contains the error along with the details of that error
and possible solutions.
14. Discuss any four advantages of .Net.
b. Great Caching System: The simplicity of the caching system of .NET makes it
reliable and easy to come temporarily store data. it allows for the cache
implementation to be customized, so developers can improve performance and scale
as needed.
c. Visual Studio: NET comes with the Visual Studio Integrated Development
Environment (IDE). This tool allows developers to create applications without much
difficulty, as well as debug and publish them across multiple platforms and OS.
CLR is the basic and Virtual Machine component of the .NET Framework. It is
the run-time environment in the .NET Framework that runs the codes and helps in making the
development process easier by providing the various services.
a. Suppose you have written a VB program and save it in a file which is known as the
Source Code.
b. Language specific compiler compiles the source code into the MSIL(Microsoft
Intermediate Language) which is also known as the CIL(Common Intermediate
Language) or IL(Intermediate Language) along with its metadata. Metadata includes all
the types, actual implementation of each function of the program. MSIL is machine-
independent code.
c. Now CLR comes into existence. CLR provides the services and runtime environment to
the MSIL code.CLR includes the JIT(Just-In-Time) compiler which converts the MSIL
code to machine code which further executed by CPU.
Advantages of CLR
It improves the performance by providing a rich interact between programs at run time.
Enhance portability by removing the need of recompiling a program on any operating system
that supports it.
Security also increases as it analyzes the MSIL instructions whether they are safe or unsafe.
Support automatic memory management with the help of Garbage Collector.
There are 2 Types of CTS that every .NET programming language have :
1. Value Types:
Value Types will store the value directly into the memory location.
These types work with stack mechanisms only. CLR allows memory
for these at Compile Time.
2. Reference Types:
Reference Types will contain a memory address of value because the
reference types won’t store the variable value directly in memory.
These types work with Heap mechanism. CLR allot memory for these
at Runtime.
b. A. Managed code:
The MSIL code which is managed by the CLR is known as the Managed
Code.
B. Unmanaged code:
Before .NET development, programming languages like.COM Components
& Win32 API do not generate the MSIL code. So these are not managed by
CLR rather managed by Operating System.
17. What is VB.NET? Explain any five features and advantages of VB.NET.
Features
VB.NET is not case sensitive like other languages such as C++ and Java.
It is an object-oriented programming language. It treats everything as an object.
Automatic code formatting, XML designer, improved object browser etc.
Garbage collection is automated.
Support for Boolean conditions for decision making.
Advantages
Our code will be formatted automatically.
We can use object-oriented constructs to create an enterprise-class code.
we can create web applications with modern features like performance counters, event
logs, and file system.
we can create our web forms with much ease through the visual forms designer. You
will also enjoy drag and drop capability to replace any elements that you may need.
We can connect our applications to other applications created in languages that run on
the .NET framework.
SECTION-A
A variable is nothing but a name given to a storage area that our programs can
manipulate. Each variable in VB.Net has a specific type, which determines the
size and layout of the variable's memory; the range of values that can be stored
within that memory; and the set of operations that can be applied to the variable .
A Sub procedure is a separate set of codes that are used in VB.NET programming
to execute a specific task, and it does not return any values. The Sub procedure is
enclosed by the Sub and End Sub statement.
6. what if meant by function inVB.NET?
In VB.NET, the function is a separate group of codes that are used to perform a
specific task when the defined function is called in a program. After the execution
of a function, control transfer to the main() method for further execution.
7. what is meant by standard modules in VB.NET?
A module (sometimes called a standard module) is similar to a class but with
some important distinctions. Every module has exactly one instance and does not
need to be created or assigned to a variable. Modules do not support inheritance
or implement interfaces.
8. What is VB.NET exception?
ADO.NET is a data access technology from the Microsoft . NET Framework that
provides communication between relational and non-relational systems through a
common set of components. ADO.NET is a set of computer software components
that programmers can use to access data and data services from a database.
11. What is meant by generic in vb.net.
A generic type is a single programming element that adapts to perform the same
functionality for a variety of data types. When you define a generic class or
procedure, you do not have to define a separate version for each data type for
which you might want to perform that functionality.
12. what is use of crystal reports in vb.net?
Crystal Report is a Reporting application that can generate reports from various
Data Sources. We can Create Reports, Print and Print Preview of reports from
Crystal Reports.
SECTION-B
Ten marks questions
Variable: In VB.NET, a variable is used to hold the value that can be used further
in the programming. A variable is a simple name used to store the value of a
specific data type in computer memory. In VB.NET, each variable has a particular
data type that determines the size, range, and fixed space in computer memory.
With the help of variable, we can perform several operations and manipulate data
values in any programming language.
The declaration of a variable is simple that requires a variable name and data type
followed by a Dim. A Dim is used in Class, Module, structure, Sub, procedure .
Constants:
As the name suggests, the name constant refers to a fixed value that cannot be
changed during the execution of a program. It is also known as literals. These
constants can be of any data type, such as Integer, Double, String, Decimal,
Single, character, enum, etc.
In VB.NET, const is a keyword that is used to declare a variable as constant. The
Const statement can be used with module, structure, procedure, form, and class.
Syntax:
Eg: Const constname As datatype = value
Const num As Integer = 10
14. Explain Strings and Lists in VB.net.
Strings:
In VB.NET, string is a sequential collection of characters that is called a text. The
String keyword is used to create a string variable that stores the text value. The
name of the string class is System.String that contains the various function of
string.
Declaration of the String variable
Eg: 1.Dim str As String
2.Dim abc As String
There are different ways to create a string object in the String.
To use a String class constructor.
By using the property or calling method to return a string.
Use a string literal to define a string variable.
Use a String concatenation operator (+).
By using a formatting function to convert a value or object into the string
Representation of the object.
Lists
The List class is used to store generic types of collections objects. By using a
generic class on the list, we can store one type of object. The List size can be
dynamically different depending on the need of the application, such as adding,
searching or inserting elements into a list.
Property Description
name
A Sub procedure is a separate set of codes that are used in VB.NET programming
to execute a specific task, and it does not return any values. The Sub procedure is
enclosed by the Sub and End Sub statement. The Sub procedure does not return
any value.
Defining the Sub procedure
Following is the syntax of the Sub procedure:
Function
o In VB.NET, the function is a separate group of codes that are used to
perform a specific task when the defined function is called in a program.
After the execution of a function, control transfer to the main() method for
further execution. It returns a value.
o Defining a Function
o The syntax to define a function is:
End Function
Where,
Access_Specifier: It defines the access level of the function such as public, private, or
friend, Protected function to access the method.
Function_Name: The function_name indicate the name of the function that should be
unique.
ParameterList: It defines the list of the parameters to send or retrieve data from a method.
Return_Type: It defines the data type of the variable that returns by the function.
The timer control is a looping control used to repeat any task in a given time interval. It is
an important control used in Client-side and Server-side programming, also in Windows
Services. Once the timer is enabled, it generates a tick event handler to perform any
defined task in its time interval property. It starts when the start() method of timer control
is called, and it repeats the defined task continuously until the timer stops
Name The Name property is used to set the name of the control.
Enabled The Enables property is used to enable or disable the timer control.
By default, it is True.
AutoReset The AutoReset property is used to obtain or set a Boolean value that
determines whether the timer raises the elapsed event only once.
Events Events property are used to get the list of event handler that is
associated with Event Component.
CanRaiseEvents It is used to get a value that represents whether the component can
raise an event.
Events Description
Elapsed When the interval elapses in timer control, the Elapsed event has occurred.
Tick A tick event is used to repeat the task according to the time set in the
Interval property. It is the default event of a timer control that repeats the
task between the Start() and Stop() methods.
17. Write short notes on vb.net file handling.
A file is a collection of data stored in computer memory with a specific name and a
defined folder path. The term File Handling in VB.NET is used to perform various
operations like create a file, read a file, write to the file, closing the file, and more.
Furthermore, when a file is opened for reading and writing, a stream is created.
A stream is a sequence of bytes that passes data to a file to read or write. In VB.NET file
handling, there are two types of stream such as Input Stream or Read
Stream and Output Stream or Write Stream.
The System.IO namespace has various classes that are used for performing various
operations with files, like creating and deleting files, reading from or writing to a file,
closing a file, etc.
The following table shows some commonly used non-abstract classes in the System.IO
namespace −
BinaryReader As the name represents, a Binary reader is used to read primitive data
in a binary stream.
FileStream Class
The FileStream class is provided by the System.IO namespace to read, write, close or
create files in the file handling.
Parameter Description
FileMode The FileMode represents the various method for opening or creating a
file. Following are the member of FileMode-
Append: It is used to open an existing file and put the cursor at the end of
the file. And if the file is not existing, it creates a file.
Create: As the name defines, a create is uses to create a new file.
CreateNew: It specifies the OS to create a new file.
Open: It is used to open an existing file.
OpenOrCreate: It is used to open an existing file, and if the file is not
existing, it creates a new file.
Truncate: It is used to open an existing file for shrinking its original size
to zero bytes.
FileAccess It is used to perform any operation such as Read, ReadWrite, Delete and
Write, etc.
Inheritance Syntax
The following is the syntax of Inheritance in VB.NET.
VB.NET only supports single inheritance that means a class can be inherited from the
base class. However, VB.NET uses hierarchical inheritance to extend one class to another
class, which is called Multi-LevelInheritance .
19. a. What is custom control?
b. What is user control?
c. Differentiate between custom control and user control.
a. custom control is a loosely coupled control defined in a class, which derives from
Control. The UI of the custom control is generally defined in a Resource Dictionary inside
the resource file. They are created according to the requirement of the business .
a. user control The base User Control is nothing but a Custom Control that you derive to
create a control UI specific to your application. It provides the reusability of design and
are created in the same way as a web form.
The main difference between Custom Control and User Control is thatthey inherit from
different levels in the inheritance tree .
A Custom Control generally inherits from the System.Windows.Controls.Control class.
You may derive from a different custom control depending on your requirement.
A UserControl inherits from the System.Windows.Controls.UserControls class, which
inherits from the base "Control" class.
20. a. What is ADO.NET?
b. Mention difference between ado.net and ado.
a. -ADO.NET
ADO.NET is a data access technology from Microsoft .Net Framework , which provides
communication between relational and non-relational systems through a common set of
components . ADO.NET was built for a disconnected architecture , so it enables truly
disconnected data access and data manipulation through its Dataset Object, which is
completely independent from the Data Source.
The two key components of ADO.NET are Data Providers and DataSet .
It is used to access data independently from any data resource. DataSet contains a
collection of one or more DataTable objects of data.
b. Difference between ado and ado.net
ADO stands for ActiveX Data Objects. In this the programmers use a generic set of objects, no
matter the underlying data sources. It requires locking of database resources and a lengthy
connections for applications. In ADO connection is creating by using a single Connection object.
ADO.NET:ADO.NET is an advance version of ADO. It interacts with databases and have a
consistent access to various data sources. It does not requires locking and a lengthy connections
for its applications. ADO.NET can have separate objects that represent connections to
different data sources which make access faster and more efficient.
UNIT-3 PROGRAMMING IN VISUAL BASIC.NET
SECTION-A
Two marks questions
1 .What is a data type?
A Data Type refers to which type of data or value is assigning to a variable or function
so that a variable can hold a defined data type value.
For example, when we declare a variable, we have to tell the compiler what type of data
or value is allocated to different kinds of variables to hold different amounts of space in
computer memory.
Syntax:
In VB.NET, operator is a special symbol that tells the compiler to perform the specific
logical or mathematical operation on the data values. The data value itself (which can be
either a variable or a constant) is called an operand, and the Operator performs
various operations on the operand.
The Arithmetic Operators
o The Arithmetic Operators in VB.NET, used to perform mathematical operations such
as subtraction, addition, multiplication, division, etc. on the operands in VB.NET.
operator
o Eg: The addition Operator –‘ X + Y’
o exponentiation Operator-‘ X^Y’
3. Discuss the scope and lifetime of a variable.
A Variable’sScope: The scope of a variable is the section of the application that can see
and manipulate the variable. If a variable is declared within a procedure, only the code in
the specific procedure has access to that variable. When the variable’s scope is limited to
a procedure it’s called local.
Lifetime of a Variable : It is the period for which they retain their value. Variables
declared as Public exist for the lifetime of the application. Local variables, declared
within procedures with the Dim or Private statement, live as long as the procedure.
4 . Explain select case statement with the syntax.
In VB.NET, the Select Case statement is a collection of multiple case statements, which
allows executing a single case statement from the list of statements. A selected case
statement uses a variable to test for equality against multiple cases or statements in a
program. If the variable is matched with any test cases, that statement will be executed.
And if the condition is not matched with any cases, it executes the default statement.
Syntax
Following is the syntax of the Select Case statement in VB.NET, as follows:
In the VB.NET, For Each loop is used to iterate block of statements in an array or
collection objects. Using For Each loop, we can easily work with collection objects such
as lists, arrays, etc., to execute each element of an array or in a collection. And when
iteration through each element in the array or collection is complete, the control
transferred to the next statement to end the loop.
Syntax :
With objExpression
[ Statements to be Executed]
End With
7. How to use MDI in VB.Net?
MDI stands for Multiple Document Interface applications that allow users to work with
multiple documents by opening more than one document at a time. Whereas, a Single
Document Interface (SDI) application can manipulate only one document at a time.
The MDI applications act as the parent and child relationship in a form. A parent form is
a container that contains child forms, while child forms can be multiple to display
different modules in a parent form.
o -With multiple-document interfaces a single menu bar and/or toolbar is shared between
all child windows, reducing clutter and increasing efficient use of screen space.
o -An application's child windows can be hidden/shown/minimized/maximized as a whole.
8. Explain any two built in date functions.
o The Date data type contains date values, time values, or date and time values. The default
value of Date is 0:00:00 (midnight) on January 1, 0001. The equivalent .NET data type
is System.DateTime.
o i.Public Function Add (value As TimeSpan) As DateTime
Returns a new DateTime that adds the value of the specified TimeSpan to
the value of this instance.
o ii . Public Function AddDays( value As Double) As DateTime
Returns a new DateTime that adds the specified number of days to the
value of this instance
The function is a separate group of codes that are used to perform a specific task
when the defined function is called in a program. After the execution of a
function, control transfer to the main() method for further execution. It returns a
value.
Syntax
Data types refer to an extensive system used for declaring variables or functions
of different types. The type of a variable determines how much space it occupies
in storage and how the bit pattern stored is interpreted .
Dim b AsByte
Dim n AsInteger
Dim da AsDate
Dim c AsChar
b =1
n =1234567
da=Today
c ="U"
12. Mention any two decision making statements with syntax with a vb.et program.
If condition Then
[Statement or block of Statement]
End If
Module Module1
' Declaration of variable str
Dim str As String = "University"
Sub Main()
' if str equal to "University", below Statement will be executed.
If str = "University" Then
Console.WriteLine("Welcome to the University")
End If
Console.WritLine("press any key to exit?")
Console.ReadKey()
End Sub
End Module
If-Then-Else Statement
o The If-Then Statement can execute single or multiple statements when the condition is
true, but when the expression evaluates to false, it does nothing. So, here comes the If-
Then-Else Statement. The IF-Then-Else Statement is telling what If condition to do
when if the statement is false, it executes the Else statement.
o syntax :
If (Boolean_expression) Then
'This statement will execute if the Boolean condition is true
Else
'Optional statement will execute if the Boolean condition is false
End If
Example:
Write a program to check whether the number is even or odd.
Module If_Else_statement
Sub Main()
Dim num As Integer
Console.WriteLine("Enter the Number")
num = Console.ReadLine() 'read data from console
13. Mention any two looping statements with syntax and example.
o A Loop is used to repeat the same process multiple times until it meets the specified
condition in a program. By using a loop in a program, a programmer can repeat any
number of statements up to the desired number of repetitions.
Do While Loop
For Next loop
Do While
o In VB.NET, Do While loop is used to execute blocks of statements in the program, as
long as the condition remains true. In the Do loop, it executes the Do statements, and
then it checks the condition.
o Syntax:
Do
[ Statements to be executed]
Loop While Boolean_expression
// or
Do
[Statement to be executed]
Loop Until Boolean_expression
In the above syntax, the Do keyword followed a block of statements, and While keyword
checks Boolean_expression after the execution of the first Do statement.
Example 1. Write a simple program to print a number from 1 to 10 using the Do While loop in
VB.NET.
Imports System
Module Do_loop
Sub Main()
' Initialization and Declaration of variable i ‘
Dim i As Integer = 1
Do
' Executes the following Statement
Console.WriteLine(" Value of variable I is : {0}", i)
i = i + 1 'Increment the variable i by 1
Loop While i <= 10 ' Define the While Condition
Example 1. Write a simple program to print the number from 1 to 10 using the For Next
loop.
Imports System
Module Number
Sub Main()
' It is a simple print statement, and 'vbCrLf' is used to jump in the next line.
Console.Write(" The number starts from 1 to 10 " & vbCrLf)
' declare and initialize variable i
For i As Integer = 1 To 10 Step 1
' if the condition is true, the following statement will be executed
Console.WriteLine(" Number is {0} ", i)
' after completion of each iteration, next will update the variable counter
Next
Console.WriteLine(" Press any key to exit... ")
Console.ReadKey()
End Sub
End Module
13. Write short notes on Arrays.
VB.NET Arrays
o An array is a linear data structure that is a collection of data elements of the same type
stored on a contiguous memory location. Each data item is called an element of the
array. It is a fixed size of sequentially arranged elements in computer memory with the
first element being at index 0 and the last element at index n - 1, where n represents the
total number of elements in the array.
o Declaration of VB.NET Array
Dim array_name As [Data_Type] ()
In VB.NET, we can initialize an array with New keyword at the time of declaration.
Dim num As Integer() = New Integer(5) { }
Dim num As Integer() = New Integer(5) {1, 2, 3, 4, 5, 6}
we can also initialize and declare an array using the following ways, as shown below.
Multidimensional Array
o In VB.NET, a multidimensional array is useful for storing more than one dimension in a
tabular form, such as rows and columns. The multidimensional array support two or three
dimensional in VB.NET.
o Declaration of Multidimensional Array
o Representation of Two Dimensional array
The above representation of the fixed array is that we have defined a string array names
0 to 4, which stores all the elements in the array from 0 to index 4 .
For i = 1 To number
fact = fact * i
Next
15. Write short notes on any four vb.net string functions with an example.
String Functions
Format function
This function is used to arrange the string in a particular format.
Example
Input
Dim ChangedTime As Date = #03/23/2019 4:10:43 PM#
Dim ChangedTime as the string
ChangedTime = Format(TestDateTime, "h:m:s")
Output: 04:10:43 PM
Join function
Example
Input
Dim ItemList() As String = {“Apple”, “Banana”, “Guava”}
Dim JoinItemList as string = Join(ItemList, ", ")
Output: Apple, Banana, Guava
LCase Function
This function will convert all the characters of the string into a lowercase
character. If the character is already in lowercase that it will ignore the character
else will convert that into lowercase.
Example
Input
Dim Uppercase as String = “HELLO WORLD”
Dim Lowercase as String = LCase(Uppercase)
Output: hello world
Len function
This String function in VB.Net will return the numbers of characters in a string.
The value returned will be an integer value so it has to be stored in the integer
variable.
Example
Input
Dim StrWords as String = “You are a hero!”
Dim WordCount as Integer = Len(StrWords)
Output: 15
16. Write short notes on any four vb.net mathematical functions with example.
Math functions are very useful function when we need to perform mathematical
operations such as some trigonometric and logarithmic. To use these math functions
without qualification, import the System.Math namespace .
1. Abs() Function
The Abs Function is used to returns the absolute value of a specified number.
Syntax: Math.Abs(n)
Here, n is the number
This function returns the absolute value.
2. Min() Function
The Min function is used to find out the minimum value from two number.
Syntax
Math.Min(n1, n2)
Here, n1 and n2 are the two number.
This function returns the min value from n1 and n2.
3. Max() Function
The Max function is used to find out the maximum value from two number.
Syntax
Math.Max(n1, n2)
Here, n1 and n2 are the two number. This function returns the maximum value from n1 and
n2.
4. Sqrt() Function
The Sqrt function is used to returns the square root of the number.
Syntax
Math.Sqrt(n1)
Here, n1 is the number.
This function returns the maximum value from n1 and n2.
This function returns a Double value specifying the square root of a number.
Module Module1
Sub Main()
Dim absolute As Integer
absolute = Math.Abs(-16)
Console.WriteLine("The absolute value is: " & absolute)
Dim minimum As Integer
minimum = Math.Min(18, 12)
Console.WriteLine("The minimum value is: " & minimum)
Dim maximum As Integer
maximum = Math.Max(18, 12)
Console.WriteLine("The maximum value is: " & maximum)
Dim square As Integer
square = Math.Sqrt(9)
Console.WriteLine("The square root is: " & square)
End Sub
End Module
A function is a group of statements that together perform a task when called. After the
function isexecuted, the control returns to the statement calling the function.A function
return a value.
Defining a Function
The Function statement is used to declare the name, parameter and the body of a function.
The syntax for the Function statement is −
[Statements]
End Function
Where,
o Modifiers − specify the access level of the function; possible values are: Public,
Private, Protected, Friend, Protected Friend and information regarding overloading,
overriding, sharing, and shadowing.
o FunctionName − indicates the name of the function
o ParameterList − specifies the list of the parameters
o ReturnType − specifies the data type of the variable the function returns
Example: a function FindMax that takes two integer values and returns the larger of the two.
In VB.Net, a function can return a value to the calling code in two ways −
By using the return statement
By assigning the value to the function name
res = FindMax(a, b)
Console.WriteLine("Max value is : {0}", res)
Console.ReadLine()
End Sub
End Module
Sub procedures are procedures are just like function butt do not return any value
o The Sub statement is used to declare the name, parameter and the body of a sub
procedure. The syntax for the Sub statement is –
Where,
Modifiers − specify the access level of the procedure; possible values are - Public, Private,
Protected, Friend, Protected Friend and information regarding overloading, overriding,
sharing, and shadowing.
SubName − indicates the name of the Sub
ParameterList − specifies the list of the parameters
Example
The following example demonstrates a Sub procedure CalculatePay that takes two
parameters hours and wages and displays the total pay of an employee −
Module mysub
Sub CalculatePay(ByRef hours As Double, ByRef wage As Decimal)
'local variable declaration
Dim pay As Double
pay = hours * wage
Console.WriteLine("Total Pay: {0:C}", pay)
End Sub
Sub Main()
'calling the CalculatePay Sub Procedure
CalculatePay(25, 10)
CalculatePay(40, 20)
CalculatePay(30, 27.5)
Console.ReadLine()
End Sub
End Module
UNIT-4 ASP.NET BUILDING A WEB APPLICATION
SECTION-A
Two marks questions
1 . List any two properties of button control
o The Button control represents a standard Windows button. It is generally used to
generate a Click event by providing a handler for the Click event.
o Properties of the Button Control
1. AutoSizeMode
Gets or sets the mode by which the Button automatically resizes itself.
2. BackColor
Gets or sets the background color of the control.
BorderStyle: Gets or sets the border type of the text box control.
A GroupBox may have a visible caption, whereas the Panel does not.
A GroupBox always displays a border; a Panel’s border is determined by its BorderStyle
property. It may be set to BorderStyle.None, BorderStyle.Single, or
BorderStyle.Fixed3D.
A GroupBox does not support scrolling; a Panel enables automatic scrolling when its
AutoScroll property is set to true.
o ActivateMdiChild:
-Activates the MDI child of a form
6. What is data binding in vb.net? Mention any two data binding controls.
The .Net allows powerful feature of data binding, you can bind any server control to
simple properties, collections, expressions and/or methods. When you use data
binding, you have more flexibility when you use data from a database or other means.
Data binding provides simple, convenient, and powerful way to create a read/write
link between the controls on a form and the data in their application.
Data binding allows you to take the results of properties, collection, method calls, and
database queries and integrate them with your ASP.NET code
Data Bind Control can display data in connected and disconnected model.
SECTION-B
Ten marks questions
11. A) Describe the PasswordChar, ReadOnly, Multiline ,Text and
WordWrapproperties of textbox.
B) Explain InputBoxfunction with example.
Ans . A)
a)PasswordChar
Gets or sets the character used to mask characters of a password in a single- line
TextBox control.
b)ReadOnly
Gets or sets a value indicating whether text in the text box is read-only.
c ) Multiline
Gets or sets a value indicating whether this is a multiline TextBox control.
d)Text
Gets or sets the current text in the TextBox.
e) WordWrap
Indicates whether a multiline text box control automatically wraps words to the
beginning of the next line when necessary
B) InputBox Function
In Visual Basic .NET InputBox Function displays a prompt in a dialog box and waits
for the user to write some text and click on the OK button. If the user clicks the OK
button, the InputBox function will returns the contents to the text box. If the user
clicks on the Cancel button, the function will return an empty string ("").
Example:
The following code shows you the InputBox function. Drag a Button1and
a TextBox control from the toolbox onto the form. Place the code below in the click
event of the Button1.
12. List any five properties, three methods and two events of ListBox.
The ListBox represents a Windows control to display a list of items to a user. A user can
select an item from the list. It allows the programmer to add items at design time by using the
properties window or at the runtime.
Properties
o AllowSelection
Gets a value indicating whether the ListBox currently enables selection of list items.
o BorderStyle
Gets or sets the type of border drawn around the list box.
o ColumnWidth
Gets of sets the width of columns in a multicolumn list box.
o HorizontalExtent
Gets or sets the horizontal scrolling area of a list box.
o Items
Gets the items of the list box.
Methods
o BeginUpdate
Prevents the control from drawing until the EndUpdate method is called, while items
are added to the ListBox one at a time.
o ClearSelected
Unselects all items in the ListBox.
o EndUpdate
Resumes drawing of a list box after it was turned off by the BeginUpdate method.
Events
o Click
Occurs when a list box is selected.
o SelectedIndexChanged
Occurs when the SelectedIndex property of a list box is changed .
Ans: A.
TheDateTimePicker control allows selecting a date and time by editing the displayed
values in the control. If you click the arrow in the DateTimePicker control, it displays a
month calendar, like a combo box control. The user can make selection by clicking the
required date. The new selected value appears in the text box part of the control.
Properties of DateTimePicker
1.BackColor
Gets or sets a value indicating the background color of the DateTimePicker
control.
2.BackgroundImage
Gets or sets the background image for the control.
3.CalendarFont
Gets or sets the font style applied to the calendar.
4.MaxDate
Gets or sets the maximum date and time that can be selected in the control.
5.MinDate
Gets or sets the minimum date and time that can be selected in the control.
B.ImageList Control
The ImageList is a simple control that stores images used by other controls at
runtime. ImageList is typically used by other controls, such as
the ListView, TreeView, or ToolBar. You can add bitmaps or icons to
the ImageList, and the other controls are able to use the images as they require.
For example, a TreeView control can use icons to identify its nodes
The simplest and quickest method of preparing these images is to create an ImageList
control and add to it all the icons you need for decorating the TreeView control’s
nodes. The ImageList control maintains a series of bitmaps in memory that the
TreeView control can access quickly at runtime.
Tooltip.
The ToolTip control is used to display some text when the mouse is move over a
control. This control is helpful in providing quick information when the user moves
the pointer over an associated control.
Tooltips can be attached to any active element (icons, text links, buttons, etc.) on a
page. They provide descriptions or explanations for their paired element. Thus,
tooltips are highly contextual and specific and don’t explain the bigger picture or
entire task flow.
End Sub
In the above list, we can select more than one item from the CheckedListBox in Windows Form.
After that, click on the Select button to display the selected item in Windows Form.
15 . List the build in dialog controls in vb.net. Explain any two of them.
There are many built- in dialog boxes to be used in Windows forms for various tasks like
opening and saving files, printing a page, providing choices for colors, fonts, page setup,
etc., to the user of an application. These built-in dialog boxes reduce the developer's time
and workload.
All of these dialog box control classes inherit from the CommonDialog class and override
the RunDialog() function of the base class to create the specific dialog box.
16 .Write notes on TreeView control and TreeNode class. Mention any five properties
o BackColor
Gets or sets the background color of the tree node.
o Checked
Gets or sets a value indicating whether the tree node is in a checked state.
o ContextMenu
Gets the shortcut menu that is associated with this tree node.
o ContextMenuStrip
Gets or sets the shortcut menu associated with this tree node.
o FirstNode
Gets the first child tree node in the tree node collection.
UNIT-5 DATABASES
SECTION-A
Two marks questions
1. What is meant by Data Connection Object?
The connection object is used to open a connection to your database (data source). The
SqlConnectioninstance takes Connection String as argument and pass the value to the
Constructor statement. The Open() method in SqlConnection class is used to open the
Database Connection and The Close() method in SqlConnection class is used to close the
Database Connection.
2. State the difference between data set and data reader.
There are two common ways to write a LINQ query to data sources.
-Query syntax or Expression syntax
-Method syntax or method Extension Syntax
o Query syntax is similar to Structured Query Language for the database. It is described
within VB code.
Syntax
from <range variable> in <IEnumerable<T> or IQueryable<T> Collection>
<specific Query Operators> <lambda expression>
<select or groupBy operator> <result formation>
SECTION-B
Ten marks questions
11. Explain briefly ADO.NET Architecture. What is a Connection class and Connection
string?
o ADO.NET uses a multilayer architecture that mainly has a few concepts, for instance
Connection, Reader, Command, Adapter and Dataset objects. ADO.NET introduced
data providers that are a set of special classes to access a specific database, execute
SQL commands and retrieve data. The Data providers are extensible. Developers can
create their own providers for a proprietary data source. There are some examples of
data providers such as SQL Server providers, OLE DB and Oracle provider.
o Connection-based:
They are the data provider objects such as Connection, Command,
DataAdapter, and DataReader. They execute SQL statements and connect
to a database.
o Content-based:
They are found in the System.Data namespace and includesDataSet,
DataColumn, DataRow, and DataRelation. They are completely
independent of the type of data source.
ADO.NET Namespaces
o System.Data:
Contains the definition for columns,relations,tables,database,rows,views
and constraints.
o System.Data.SqlClient:
Contains the classes to connect to a Microsoft SQL Server database such
as SqlCommand, SqlConnection, and SqlDataAdapter.
o System.Data.Odbc:
Contains classes required to connect to most ODBC drivers. These classes
include OdbcCommand and OdbcConnection.
o System.Data.OracleClient:
Contains classes such as OracleConnection and OracleCommand required
to connect to an Oracle database.
Connection Class
Connection class object is used for inserting, updating, deleting and retrieving data from
a database. The Connection class allows you to establish a connection to the data source.
The Connection class object needs the necessary information to discover the data source
and this information is provided by a connection string.
Connection Strings
we need to supply a connection string in the Connection class object. The connection
string is a series of name/value settings separated by semicolons (;). A connection string
requires a few pieces of information such as the location of the database, the database
name, and the database authentication mechanism.
ADO.NET DataAdapter
o The DataAdapter serves as a bridge between a DataSet and a data source for
retrieving and saving data.
o The DataAdapter provides this bridge by mapping Fill, which changes the data in the
DataSet to match the data in the data source, and Update, which changes the data in
the data source to match the data in the DataSet.
o The methods are
DataAdapter.Fill(DataSet)
DataAdapter.Fill(DataTable)
o The Fill method retrieves rows from the data source using the SELECT statement
specified by an associated SelectCommand property.
o If the data adapter encounters duplicate columns while populating a DataTable, it
generates names for the subsequent columns, using the pattern "columnname1",
"columnname2", "columnname3", and so on.
From the following program you can understand how to use DataAdapter.Fill method in
VB.NET applications.
Imports System.IO
Imports System.Data.SqlClient
Public Class Form1
Dim cnn As SqlConnection
Dim connectionString As String
Dim sqlAdp As SqlDataAdapter
Dim ds As New DataSet
Dim dt As New DataSet
sqlAdp.Fill(ds)
sqlAdp.Fill(dt)
DataBinding:
is a powerful feature provided by the .NET Framework that enables visual elements in a
client to connect to a datasource such as DataSets, DataViews, Arrays, etc. Some of the
visual elements in the client can be TextBox, Datagrid, etc. A two-way connection is
established such that any changes made to the datasource are reflected immediately in the
visual element and vice versa.
Advantages of DataBinding
Databinding in .NET can be used to write data driven applications quickly. .NET data
binding allows you to write less code with fast execution but still get the work done in the
best way.
.NET automatically writes a lot of databinding code for you in the background (you can
see it in "Windows Generated Code" section), so the developer does not have to spend
time writing code for basic databinding, but still has the flexibility of modifying any code
that he would like to. We get the benefits of bound as well as unbound approach.
Control over the Databinding process by using events.
14. Explain the following SELECT command ,using WHERE clause,, using ORDERBY
clause with example.
The SQL SELECT statement is used to fetch the data from a database table which returns
this data in the form of a result table. These result tables are called result-sets.
Syntax
The basic syntax of the SELECT statement is as follows −
SELECT column1, column2, columnN FROM table_name;
Example:SELECT * FROM table_name;
The SQL WHERE clause is used to specify a condition while fetching the data from a
single table or by joining with multiple tables. If the given condition is satisfied, then
only it returns a specific value from the table
Syntax
The basic syntax of the SELECT statement with the WHERE clause is as shown below.
SELECT column1, column2, column FROM table_name
WHERE [condition]
Example: SELECT ID, NAME, SALARY
FROM CUSTOMERS
WHERE SALARY > 2000;
The SQL ORDER BY clause is used to sort the data in ascending or descending order,
based on one or more columns.
Syntax
The basic syntax of the ORDER BY clause is as follows −
SELECT column-list
FROM table_name
[WHERE condition]
[ORDER BY column1, column2, ..columnN] [ASC | DESC];
15. A. What is LINQ? Mention any advantages LINQ. What are the types of LINQ?
Advantages
LINQ offers a common syntax for querying any type of data sources
it binds the gap between relational and object-oriented approachs.
LINQ expedites development time by catching errors at compile time and includes
IntelliSense & Debugging support
LINQ expressions are Strongly Typed..
Types of LINQ
LINQ To Objects
The term "LINQ to Objects" refers to the use of LINQ queries with any IEnumerable or
IEnumerable<T> collection directly, without the use of an intermediate LINQ provider or
API such as LINQ to SQL or LINQ to XML.
LINQ To DataSets
LINQ to DataSet makes it easier and faster to query over data cached in a DataSet object.
Specifically, LINQ to DataSet simplifies querying by enabling developers to write
queries from the programming language itself, instead of by using a separate query
language.
LINQ To SQL
LINQ to SQL fully supports transactions, views, and stored procedures. It also provides
an easy way to integrate data validation and business logic rules into your data model.
This example defines the basic idea of LINQ to SQL Query using code.
LINQ to XML
LINQ to XML is an in-memory XML programming API designed specifically to take
advantage of Language-Integrated Query (LINQ).