vb - ticstanda.com · vb.net q1.introduction of visual basic? ans-: visual basic is a third...
TRANSCRIPT
VB.NET
Q1.Introduction of visual basic?
Ans-:visual basic is a third generation event driven programming language &
integrated development environment from Microsoft for its released in
1991.Microsoft intended visual basic to relating easy to learn and use.
Elements of Visual Basic-:The two basic elements of visual basic are GUI and the
code associated with the application that makes it respond to event occurred as a
result of a user action.
Elements-: IDE is a term commonly used in the programming world to described
the interface and environment that we use to create our applications. it is called
integrated because we can access virtually all of the development tools that we
need from one screen called on interface. The IDE is also commonly referred to as
the design environment or the program.
The visual basic IDE is made up of a number of components-:
IDE-: Integrated Development Environment
1. Menu bar
2. Tool bar
3. Project explorer
4. Properties window
5. from layout window
6. Toolbar
7. from designer
8. Object browser
Introduction of VB.Net-:VB.Net is a simple modern, object oriented computer
programming language developed by Microsoft to combine the power of.net
framework and the common language runtime with the productivity benefits that
are hallmark of visual basic.
Vb.net has complete support for object oriented concepts. Everything in vb.net is
an object including all of the primitive types (short, integer, long, string, Boolean
etc) and user defined types, events and event assembler. All objects inherit from
the basic class objects.
V . et fra e ork is i ple e t y Mi rosoft’s net framework.therfore it has full
access to all the libraries in the .net framework. It is also possible to run vb.net
program on mono the open source alternative to .net not only under window but
even Linux or Mac OSx.
The following reasons make vb.net a widely used professional language-:
1. Modern general purpose
2. Object oriented
3. Component oriented
4. easy to learn
5. Structured programming
6. It produces efficient programming
7. It can be complied on a variety of computer platform.
8. Part of net. Framework
The .Net framework The .net framework is a revolutionary platform that helps you to write the
following types of applications.
1) Window applications
2) Web applications
3) Web services
The .net framework applications are multiplatform applications. The
framework has been designed in such a way that it can be used from any of
the following languages visual basic, c#, c++, java script and Cobol etc.
The .net framework consists of an various library of codes used by the client
language like vb.net.these language use object oriented methodology.
There is some following same of the components of the .net framework.
common language runtime(CLR)
the .net framework class library
Common language specification.
Common type system
Metadata and assembler
Windows forms
Asp.net and asp.net Ajax
Ado.net
Window workflow foundation(wf)
Window presentation foundation(wcf)
Window communication foundation(wcf)
Linq
Review Q1what are the two major features of visual basic?
Ans-:1) GUI Interface-:vb is a graphical user interface language. This means that a
vb program will always show something on the screen that the user can interact e
with (usually via mouse and keyboard) to get a job done.
2) Modularization-: it is considered good programming practice to modular your
programs. Instead of thinking of a computer program as a single large collections
of code the good programming writes code so that you never need to lock at
more code than fits on the screen(or page)at one time.
3)Object orientation-: object oriented programming is a concept where the
programming thinks of the program in objects that interact with each others. In
oop all the code associated with that object is in one place.
Q2.Write a short note on CLR?
Ans-: CLR stands for common language runtime. It is a managed execution
environment that is a part of Mi rosoft’s et fra e ork. lr a ages the execution of programs written in different supported language clr transforms
source code into a form of bytes code from known common intermediate
language(cil) at runtime clr handles the execution of the cil code.
Q3. What is managed code?
Ans-:managed code is a term coined by Microsoft to identify computers
programming code that requires and will execute only under the management of
a common language runtime virtual machine typically the net framework mono
managed code usually refer to program written in .net language such as c# or
visual basic.net while in managed code refer to program written in c,c++,visual
basic and other language that do not need a runtime to execute.
Q4.Why is JIT needed?
Ans-:jit stands for just in time. Just in time compilation the process of converting
cil to machine code translation. In .net word it is done by jit complier code in
dynamic memory. It means that you will compile yours application twice that you
will compile your applications twice if you run it two times simultaneously.
Q5.What do you mean by MSIL?
Ans-: MSIL stand for Microsoft intermediate language. We can call it as
intermediate language (il) or common intermediate language.
During the compile time the complier convert the source code into
Microsoft intermediate language (msil).Microsoft intermediate language is a cpu
independent set of instructions that can be efficiently converted to the negative
code. During the runtime the common language runtime the common language
ru ti e lr ’s just i time (jit) compiler converts the Microsoft intermediate
language (msil) code into native code to the operating system.
Q6.Explain the concept of assemblies?
Ans-: Microsoft .net assembly is a logical unit of a code that contain code which
the commonly language runtime (clr) executes. It is the smallest unit of
development of a .net applications and it can be .dll or an exe. Assembly is really
Collections of types a d resour e i for atio ’s that are uild to ork together and from a logical unit of functionality. Assemblies are the building block of .net
framework applications. During the compile time metadata is created with
Microsoft intermediate language (msil) and stored in a file called assembly
manifest. Both metadata and Microsoft intermediate language together wrapped
in a portable executable (pe) file.
Q.7 What is CTS?
Ans-: Common type systems (cts) describe a set of types that can be used in
different .net language in common. That is the common type systems (cts) ensure
that objects written in different .net languages can interact with each other. For
communicating between programs written in any .net complaints language the
types have to be compatibles on the basic level.
These types can be value types or reference type. The values types are passed by
values are stored in the stack. The reference type are passed by reference and
stored in the heap. Common type systems (cts) provide base set of data types
which is responsible for cross language integrated. The common language
runtime(clr) can load and execute the source code written in any .net language
only if the types Is described in the common type system(cts).most of the
members defined by types in the .net framework class library (fcl) are common
language specification(cls) complaint types.
Q.Differentiate between values and reference types?
Ans-: value types-: the value types are passed by values and stored in the stack.
When you created a value types a single space in memory is allocated to store the
value and that variable directly holds a value. If you assign it to another variable
the value is copied directly and both variables work independently .predefined
datatypes,structure,enum are also value types and work in the same way values
a d stored i sta k e ory e ause of this gar arge olle tor a ’t a ess the stack.
Reference types-: the reference types are passed by reference and stored in the
heap. Reference type are used by a reference which holds a reference (address)
to the object but not the object itself.beacuse reference types represent the
address of the variable rather than the data itself.beacause reference types
represent the address of the variable rather than the data itself assigning a
refere e aria le to a other does ’t opy the data. Refere e type aria le are stored in a different area of memory called the heap. This means that when a
reference type’s variable is no longer used, it can be marked for garbage
collection. Example of reference types are classes, objects, array, and indexes
interfaces etc.
Q Explain the different kinds of literals?
Ans-: a literal is a textual representation of a particular value of a type. Literal
types include Boolean, integer, floating point string, character and data.
UNIT-2 Q Define a variable?
Ans-: variable are used to store data. a variable as a name to which we refer and
the data type the type of data the variable holds.a variable is nothing but a name
given to storage area that our programs can manipulate. Each variable in vb.net
has a spe ifi type hi h deter i es the size a d layout of the aria le’s e ory the rangeof values that can be stored with in that memory and set of operations
that can be memory and set of operations that can be applied to the variable.we
have already discussed various data types.the basic value type provided in vb.net
can be categorized as-:
Integer,float,decimal,Boolean,data types
Q Declaring of variable?
Ans-: the dim statement is used for variable declaration and storage allocation for
one or more variables. The dim statement is used at module class structure
procedure or block level variables are declared with the dim keyword.dim stands
for dimensions.
Some valid variable declarations along with their definitions are show here-:
Dim studentid as integer
Dim studentsname as string
Dim salary as double
Dim count1,count2 as integer
Dim status as Boolean
Dim exit button as new style system win down forms button
Dim lasttime,next time as date.
Variable intilization in vb.net-:
Variable are initized (assigned a value) with an equal sign followed by a constant
expression.the general form of initialization is-:
Variable _name=value;
For example-:
Dim As Integer
A=15;
You can initialize a variable at the time of declaration as follows-:
Dim StudentID As Integer=100;
Di “tude tNa e As “tri g= Bill “ ith
Example-:
Modules Variable N data Types
Sub Main()
Dim a As Integer=10
Dim b As Integer=5
Dim c As Integer
C=a+b;
Co sole.WriteLi e su of a& = &
End Sub
End Module
Q Scope of variable?
Ans-:the scope of an element in code that can refer to it without qualifying its
a e stated other ay a ele e t’s scope is its accessibility in code.scope is
normally used when writing large programs as large programs divide code into
different classes,modules etcthe different kinds of scope avialible in vb.net are as
follows-:
1)Block Scope-:the element declared is available only within the code block in
which it is declared.
2)Procedure Scope-:The element declared is available only with in the procedure
in which it is declared.
3)Module Level-:the element is available to all code within the module and class
in which it is declared.
4) Namespace Scope-: the element declared is available to all code in the
namespaces.
QVB.NET operators?
ANS-: there are various operators in vb.net.
1) Arithmetic operator
2) Relational operator
3) Logical operator
4) Assignment operator
1) Arithmetic operator-: arithmetic operator is used to mathematical calculations
such as +,-,*,/,% etc.assume variable a hold 2 and b hold 7 then
Operator Description Example
+ Adds two operands A + B will give 9
- Subtracts second operand from the first A - B will give -5
* Multiplies both operands A * B will give 14
/ Divides one operand by another and
returns a floating point result B / A will give 3.5
\ Divides one operand by another and
returns an integer result B \ A will give 3
MOD Modulus Operator and remainder of after
an integer division B MOD A will give 1
Module Module1
Sub Main()
Dim a As Integer=10
Dim b As Integer=20
Console.WriteLine (a+b)
Console.WriteLine (a-b)
Console.WriteLine (a*b)
Console.WriteLine (a%b)
Console.WriteLine (a/b)
End Sub
End Module
2) Relational operator-: this operator is used to compare two values. It is also
called as compression operator. Assume variable a hold 10 and variable b hold 20
then-:
Operator Description Example
=
Checks if the values of two operands are
equal or not; if yes, then condition
becomes true.
(A = B) is not true.
<>
Checks if the values of two operands are
equal or not; if values are not equal, then
condition becomes true.
(A <> B) is true.
>
Checks if the value of left operand is
greater than the value of right operand; if
yes, then condition becomes true.
(A > B) is not true.
< Checks if the value of left operand is less
than the value of right operand; if yes, then (A < B) is true.
condition becomes true.
>=
Checks if the value of left operand is
greater than or equal to the value of right
operand; if yes, then condition becomes
true.
(A >= B) is not true.
<=
Checks if the value of left operand is less
than or equal to the value of right operand;
if yes, then condition becomes true.
(A <= B) is true.
Module Module1
Sub Main()
Dim a As Integer=10
Dim b As Integer=5
Console.WriteLine (a>b)
Console.WriteLine (a<b)
Console.WriteLine (a=b)
Console.WriteLine (a>=b)
Console.WriteLine (a<=b)
Console.WriteLine (a!=b)
End Sub
End Module
4)Logical operator-:the logical operator supporting by vb.net assume variable a
hold Boolean value true and variable 3 holds Boolean value false then-:
Operator Description Example
And
It is the logical as well as bitwise AND
operator. If both the operands are true,
then condition becomes true. This operator
does not perform short-circuiting, i.e., it
evaluates both the expressions.
(A And B) is False.
Or
It is the logical as well as bitwise OR
operator. If any of the two operands is true,
then condition becomes true. This operator
(A Or B) is True.
does not perform short-circuiting, i.e., it
evaluates both the expressions.
Not
It is the logical as well as bitwise NOT
operator. Use to reverses the logical state
of its operand. If a condition is true, then
Logical NOT operator will make false.
Not(A And B) is True.
AND Module Module1
Sub Main()
Dim age As Integer=18
Dim height As Integer=155
If((age>18)and(height=155))Then
Console.WriteLine ( you are eligi le )
Else
Console.WriteLine ( you are ot eligi le )
EndIf
End Sub
End Module
OR Module Module1
Sub Main()
Dim age As Integer=18
Dim height As Integer=155
If((age>18)OR(height=155))Then
Co sole.WriteLi e you are eligi le
Else
Co sole.WriteLi e you are ot eligi le
EndIf
End Sub
End Module
NOT Module Module1
Sub Main()
Dim age As Integer=18
If(Not age=18)Then
Co sole.WriteLi e you are eligi le
Else
Co sole.WriteLi e you are ot eligi le
EndIf
End Sub
End Module
4) Assignment operator-:these are following assignement operators supported by
vb.net-:
Operator Description Example
=
Simple assignment operator, Assigns values
from right side operands to left side
operand
C = A + B will assign value
of A + B into C
+=
Add AND assignment operator, It adds right
operand to the left operand and assigns the
result to left operand
C += A is equivalent to C =
C + A
-=
Subtract AND assignment operator, It
subtracts right operand from the left
operand and assigns the result to left
operand
C -= A is equivalent to C = C
- A
*=
Multiply AND assignment operator, It
multiplies right operand with the left
operand and assigns the result to left
operand
C *= A is equivalent to C =
C * A
/=
Divide AND assignment operator, It divides
left operand with the right operand and
assigns the result to left operand (floating
point division)
C /= A is equivalent to C = C
/ A
QData types in vb.net?
Ans-:A data type is a class that is primarily used just to hold the data.vb.net has
huge no of data types-: store any kind of data more over all the data types used
vb.net are the objects.Vb.net has a number of predefined data types-:
Data Type Storage
Allocation Value Range
Boolean
Depends on
implementing
platform
True or False
Byte 1 byte 0 through 255 (unsigned)
Char 2 bytes 0 through 65535 (unsigned)
Date 8 bytes 0:00:00 (midnight) on January 1, 0001 through
11:59:59 PM on December 31, 9999
Decimal 16 bytes
0 through +/-
79,228,162,514,264,337,593,543,950,335 (+/-
7.9...E+28) with no decimal point; 0 through +/-
7.9228162514264337593543950335 with 28 places
to the right of the decimal
Double 8 bytes
-1.79769313486231570E+308 through -
4.94065645841246544E-324, for negative values
4.94065645841246544E-324 through
1.79769313486231570E+308, for positive values
Integer 4 bytes -2,147,483,648 through 2,147,483,647 (signed)
Long 8 bytes -9,223,372,036,854,775,808 through
9,223,372,036,854,775,807(signed)
Object
4 bytes on 32-
bit platform
8 bytes on 64-
bit platform
Any type can be stored in a variable of type Object
SByte 1 byte -128 through 127 (signed)
Short 2 bytes -32,768 through 32,767 (signed)
Single 4 bytes
-3.4028235E+38 through -1.401298E-45 for negative
values;
1.401298E-45 through 3.4028235E+38 for positive
values
String
Depends on
implementing
platform
0 to appro0 to approximately 2 billion Unicode
characters
UNIT-3 DECISION MAKING AND LOOPING
Decision marking statement-: 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 statement to be executed. If the condition is
determined to be true and optionally other statement to be executed if the
condition is determined to be false. Decision making statement is two types.
1) Iteration/looping statement
2) Conditional statement
Looping statement in vb.net-: there may be a situation when you need to execute
a block of code several number of times. In general, statements are executed
sequentially .a loop statement allows use to execute a statement or group of
statement multiple times and followings is the general form of a loop statement
in most of programming languages.
There are many loops in vb.net.
1) Do loop-: it repeats the enclosed block of statement while a Boolean condition
become true .it could be terminated at any time with the exit do statement.
The syntax of this loop is-:
Do
Statement
Incre/decrement
Loop While(condition)
End Loop
Example-:
Module Module1
Sub Main()
Dim a As Integer=1
Do
Co sole.WriteLi e a
A=a+1
Loop While(a<=10)
End Sub
End Module
2)For Next Loop-:it repeats a group of statement a specified number of times and
a loop index counts the number of loop iterations as the loop executes.
The syntax for this loop as-:
For Counter [As Data Types] =Start to end
[Statement]
[Condition For]
[Statement]
[Exit For]
[Statement]
Next [Counter]
Example-:
Module Module1
Sub Main ()
Dim a As Integer
For a=1 To 20
Console.WriteLine (a)
Next
End Sub
End Module
3) While End While loop-: it execute a series of statement as long as a given
condition is true.
The syntax for this loop as-:
While Condition
[Statements]
[Condition While]
[Statements]
[Exit While]
[Statement]
End While
Example-:
Module Module1
Sub Main ()
Dim a As Integer=1
While (a<=20)
Console.WriteLine (a)
A=a+1
End Sub
End Module
4) For each next loop-: 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 as-:
For Each element[As data type] In group
[Statements]
[Condition For]
[Statements]
[Exit For]
[Statement]
Next[element]
Example-:
Module Module1
Sub Main ()
Dim a As Integer
For a=1 To 20
Console.WriteLine (a)
Next
End Sub
End Module
DECISION MAKING Statement
1)IF then Statement-: it is the simplest form of control statement. If the
condition is true then if block of code will be executed otherwise this are
specified.
Syntax-:
IF Condition Then
Statements
End If
Example-:
Module Module1
Sub Main()
Dim age As Integer=100
Dim height As Integer=5
If((a>b)Then
Co sole.WriteLi e a is greater
EndIf
End Sub
End Module
2)IF THEN ELSE STATEMENT-:an if statement can be followed by an optional else
statement which executes when the Boolean is false.
Syntax-:
IF Condition Then
Statements
Else
Statement
End If
Example-:
Module Module1
Sub Main ()
Dim age As Integer=100
Dim height As Integer=5
If ((a>b) Then
Co sole.WriteLi e a is greater
Else
Co sole.WriteLi e is greater
End If
End Sub
End Module
3)IF ELSE IF STATEMENT-:an if statement can be followed by an optional else. If
else statement which is very useful to test various conditions using single if else if
statement.
Syntax-:
IF(Boolean expression1)Then
Statements
Else If(Boolean expression2)Then
Statement
Else
Statement
End If
Example-:
Module Module1
Sub Main()
Dim day As Integer=5
If(day=1)Then
Console.WriteLine ( Sunday
Else If(day=2)Then
Co sole.WriteLi e Mo day
Else If(day=3)Then
Co sole.WriteLi e Tuesday
Else
Console.WriteLine ( I alid day
End If
End Sub
End Module
4) NESTED IF STATEMENT-: it is always legal in vb.net to nest if then else
statement. Which means you can use one if or else if statement
Inside another if else if statement.
Syntax-:
IF(Boolean expression1)Then
Statements 1
Else If(Boolean expression2)Then
Statement 2
End If
End If
Example-:
Module Module1
Sub Main()
Dim a As Integer=1000
Dim a As Integer=2000
If(daa=100)Then
If(b=200)Then
Co sole.WriteLi e a is 100 and b is 200
End If
End If
End Sub
End Module
5)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.
Syntax-:
Select [Case] expression
[Case expression list
[Statements 1]]
[Case Else
[else Statement 2]]
End select
Example-:
Module Module1
Sub Main()
Dim day As Integer=5
Select Case day
Case 1
Co sole.WriteLi e Sunday
Case 2
Co sole.WriteLi e Mo day
Case 3
Co sole.WriteLi e Tuesday
Case 4
Co sole.WriteLi e Wed esday
Case ELSE
Co sole.WriteLi e I alid Day
End Select
End Sub
End Module
UNIT-4
Array ARRAY-:an array stores a fixed size sequential collection of elements of the same
types.an array is used to store a collection of data but it is often more useful to
think of an array as a collection of variables of the same type.
All array consist of contiguous memory locations.the lowest address corresponds
to the first element and the highest address to the last element.
Declaration of an array-: to declare an array in vb.net you use the Dim
statement.
For example-: Dim int Data (30) -an array of 31 elements
Dim Str(20) As string -an array of 21 strings
Initialization of array in vb.net-: you can also initialize the array elements which
declaring while declaring the array.
for example-: Dim int Data() As Integer={12,16,20,24,28,32}
Di a es As stri g={ karthik , sa dly }
The elements in an array can be stored and accessed by using the index of the
array. The following programs demostatrets .
Module arrayAP1
Sub Main()
Dim n(10) As Integer
Dim I,j As Integer
For i=0 To 10
N(i)=i+100
Next i
For j=0 To 100
Co sole.WriteLi e ele e t is ={ } ,j, j
Next j
End Sub
End Module
MULTIDIMENSIONAL ARRAY-:vb.net allow multideminsional array.
multideminsional array are also called rectangle arrays.you can dclare
multideminsional array of strings are
Dim Two Dstring Array(10,20)As String or
threedeminsional array of Integer Variables
example-:
Module arrayAP1
Sub Main()
Dim a() As Integer={{0,0},{1,2},{2,4},{3,6},{4,8}}
Dim i,j As Integer
For i=0 To 4
For J=0 To 1
Co sole.WriteLi e a [{ },{ }]={ } ,i,j,a(i,j))
Next j
Next i
End Sub
End Module
The Array Class(System.Array Class)
The Array class is the base class for all the arrays in VB.Net. It is defined in the
System namespace. The Array class provides various properties and methods to
work with arrays.
Properties of the Array Class
The following table provides some of the most commonly used properties of the
Array class:
S.N Property Name & Description
1 IsFixedSize
Gets a value indicating whether the Array has a fixed size.
2 IsReadOnly
Gets a value indicating whether the Array is read-only.
3
Length
Gets a 32-bit integer that represents the total number of elements in all the
dimensions of the Array.
4
LongLength
Gets a 64-bit integer that represents the total number of elements in all the
dimensions of the Array.
5 Rank
Gets the rank (number of dimensions) of the Array.
Methods of the Array Class
The following table provides some of the most commonly used methods of the
Array class:
S.N Method Name & Description
1
Public Shared Sub Clear (array As Array, index As Integer, length As Integer)
Sets a range of elements in the Array to zero, to false, or to null, depending
on the element type.
2
Public Shared Sub Copy (sourceArray As Array, destinationArray As Array,
length As Integer)
Copies a range of elements from an Array starting at the first element and
pastes them into another Array starting at the first element. The length is
specified as a 32-bit integer.
3
Public Sub CopyTo (array As Array, index As Integer)
Copies all the elements of the current one-dimensional Array to the specified
one-dimensional Array starting at the specified destination Array index. The
index is specified as a 32-bit integer.
4
Public Function GetLength (dimension As Integer) As Integer
Gets a 32-bit integer that represents the number of elements in the specified
dimension of the Array.
5
Public Function GetLongLength (dimension As Integer) As Long
Gets a 64-bit integer that represents the number of elements in the specified
dimension of the Array.
6 Public Function GetLowerBound (dimension As Integer) As Integer
Gets the lower bound of the specified dimension in the Array.
7 Public Function GetType As Type
Gets the Type of the current instance (Inherited from Object).
8 Public Function GetUpperBound (dimension As Integer) As Integer
Gets the upper bound of the specified dimension in the Array.
9
Public Function GetValue (index As Integer) As Object
Gets the value at the specified position in the one-dimensional Array. The
index is specified as a 32-bit integer.
10
Public Shared Function IndexOf (array As Array,value As Object) As Integer
Searches for the specified object and returns the index of the first occurrence
within the entire one-dimensional Array.
11
Public Shared Sub Reverse (array As Array)
Reverses the sequence of the elements in the entire one-dimensional Array.
12 Public Sub SetValue (value As Object, index As Integer)
Sets a value to the element at the specified position in the one-dimensional
Array. The index is specified as a 32-bit integer.
13
Public Shared Sub Sort (array As Array)
Sorts the elements in an entire one-dimensional Array using the IComparable
implementation of each element of the Array.
14
Public Overridable Function ToString As String
Returns a string that represents the current object (Inherited from Object)
UNIT-4 BUILT IN FUNCTIONS VB.NET FUNCTIONS
A function is similar to a normal procedure but the main purpose of the function
is to accept a certain input from the user and return a value which is passed on
to the main program to finish the execution.function is a method which retirn
value function are used to evaluate data make calculation or transfer
data.decalring a function is similar to declaring a sub procedure function are
declared with the function keyword.
For ex-:
Module Function
Sub Main()
Co sole.WriteLi e su is = &add
End Sub
Public Function Add() As Interger
Dim I,j As Integer
I=10
J=20
Return(i+j)
End Function
End Module
There are two types of functions-:
1.MsgBox() Function
2. InputBox ( ) functions.
1.MsgBox() Function-: The objective of MsgBox is to produce a pop-up message
box and prompt the user to click on a command button before he/she can
continues. This format is as follows:
yourMsg=MsgBox (Prompt, Style Value, Title)
The first argument, Prompt, will display the message in the message box. The
Style Value will determine what type of command buttons appear on the message
box. The Title argument will display the title of the message board.
2. InputBox ( ) functions-:An InputBox( ) function will display a message box
where the user can enter a value or a message in the form of text. The format is:
myMessage=InputBox(Prompt, Title, default_text, x-position, y-position)
myMessage is a variant data type but typically it is declared as string, which
accept the message
input by the users. The arguments are explained as follows:
-Prompt - The message displayed normally as a question asked.
-Title - The title of the Input Box.
-default-text -The default text that appears in the input field where users can use
it as his intended input or he may change to the message he wish to key in.
-x-position and y-position - the position or the coordinate of the input box.
Type Conversion Functions-: VB.NET supports many inbuilt conversion functions
that handle the conversion of date and time, character strings, numbers and
more.
Val Function
Val FunctionIt returns the numbers contained in a string as a numeric value of
appropriate type. The Val function stops reading the string at the first character it
cannot recognize as part of a number. Symbols and characters that are often
considered parts of numeric values, such as dollar signs and commas, are not
recognized.
The Str(or Str$) Function-: It is used to return string equivalent for the specified
integer. Public Shared Function Str(ByVal Number As Object) As String.
Subroutine Functions-:
A subroutine is a block of statements that carries out a well-defined task. The
block of statements is placed within a set of Sub. . .End Sub statements and can
be invoked by name. The following subroutine displays the current date in a
message box and can be called by its
name, ShowDate():
Sub ShowDate()
MsgBox(Now().ToShortDateString)
End Sub
UNIT-6 CLASS & OBJECT
Class-: A class definition starts with the keyword Class followed by the class
name; and the class body, ended by the End Class statement. Following is the
general form of a class definition:
Syntax-:Class Classname
Statement
End Class
attributelist is a list of attributes that apply to the class. Optional.
accessmodifier defines the access levels of the class, it has values as -
Public, Protected, Friend, Protected Friend and Private. Optional.
Shadows indicate that the variable re-declares and hides an identically
named element, or set of overloaded elements, in a base class. Optional.
MustInherit specifies that the class can be used only as a base class and
that you cannot create an object directly from it, i.e., an abstract class.
Optional.
NotInheritable specifies that the class cannot be used as a base class.
Partial indicates a partial definition of the class.
Inherits specifies the base class it is inheriting from.
Implements specifies the interfaces the class is inheriting from.
Module mybox
Class Box
Public length As Double
Public breadth As Double
Public height As Double
End Class
Sub Main()
Dim Box1 As Box = New Box()
Dim Box2 As Box = New Box()
Dim volume As Double = 0.0
Box1.height = 5.0
Box1.length = 6.0
Box1.breadth = 7.0
Box2.height = 10.0
Box2.length = 12.0
Box2.breadth = 13.0
volume = Box1.height * Box1.length * Box1.breadth
Console.WriteLine("Volume of Box1 : {0}", volume)
volume = Box2.height * Box2.length * Box2.breadth
Console.WriteLine("Volume of Box2 : {0}", volume)
Console.ReadKey()
End Sub
End Module
When the above code is compiled and executed, it produces the following result:
Volume of Box1 : 210
Volume of Box2 : 1560
Member Functions and Encapsulation
A member function of a class is a function that has its definition or its prototype
within the class definition like any other variable. It operates on any object of the
class of which it is a member and has access to all the members of a class for that
object.
Member variables are attributes of an object (from design perspective) and they
are kept private to implement encapsulation. These variables can only be
accessed using the public member functions.
above concepts to set and get the value of different class members in a class:
Module mybox
Class Box
Public length As Double
Public breadth As Double
Public height As Double
Public Sub setLength(ByVal len As Double)
length = len
End Sub
Public Sub setBreadth(ByVal bre As Double)
breadth = bre
End Sub
Public Sub setHeight(ByVal hei As Double)
height = hei
End Sub
Public Function getVolume() As Double
Return length * breadth * height
End Function
End Class
Sub Main()
Dim Box1 As Box = New Box()
Dim Box2 As Box = New Box()
Dim volume As Double = 0.0
Box1.setLength(6.0)
Box1.setBreadth(7.0)
Box1.setHeight(5.0)
Box2.setLength(12.0)
Box2.setBreadth(13.0)
Box2.setHeight(10.0)
volume = Box1.getVolume()
Console.WriteLine("Volume of Box1 : {0}", volume)
volume = Box2.getVolume()
Console.WriteLine("Volume of Box2 : {0}", volume)
Console.ReadKey()
End Sub
End Module
When the above code is compiled and executed, it produces the following result:
Volume of Box1 : 210
Volume of Box2 : 1560
Constructors and Destructors
Constructors
A class constructor is a special member Sub of a class that is executed whenever
we create new objects of that class. A constructor has the name New and it does
not have any return type.
Following program explains the concept of constructor:
Class Line
Private length As Double
Public Sub New()
Console.WriteLine("Object is being created")
End Sub
Public Sub setLength(ByVal len As Double)
length = len
End Sub
Public Function getLength() As Double
Return length
End Function
Shared Sub Main()
Dim line As Line = New Line()
line.setLength(6.0)
Console.WriteLine("Length of line : {0}", line.getLength())
Console.ReadKey()
End Sub
End Class
When the above code is compiled and executed, it produces the following result:
Object is being created
Length of line : 6
Default constructor
A default constructor does not have any parameter, but if you need, a constructor
can have parameters. Such constructors are called parameterized constructors.
This technique helps you to assign initial value to an object at the time of its
creation as shown in the following example:
Class Line
Private length As Double
Public Sub New(ByVal len As Double)
Console.WriteLine("Object is being created, length = {0}", len)
length = len
End Sub
Public Sub setLength(ByVal len As Double)
length = len
End Sub
Public Function getLength() As Double
Return length
End Function
Shared Sub Main()
Dim line As Line = New Line(10.0)
Console.WriteLine("Length of line set by constructor : {0}", line.getLength())
line.setLength(6.0)
Console.WriteLine("Length of line set by setLength : {0}", line.getLength())
Console.ReadKey()
End Sub
End Class
When the above code is compiled and executed, it produces the following result:
Object is being created, length = 10
Length of line set by constructor : 10
Length of line set by setLength : 6
Destructor A destructor is a special member Sub of a class that is executed whenever an
object of its class goes out of scope.
A destructor has the name Finalize and it can neither return a value nor can it
take any parameters. Destructor can be very useful for releasing resources before
coming out of the program like closing files, releasing memories, etc.
Destructors cannot be inherited or overloaded.
Following example explains the concept of destructor:
Class Line
Private length As Double
Public Sub New()
Console.WriteLine("Object is being created")
End Sub
Protected Overrides Sub Finalize()
Console.WriteLine("Object is being deleted")
End Sub
Public Sub setLength(ByVal len As Double)
length = len
End Sub
Public Function getLength() As Double
Return length
End Function
Shared Sub Main()
Dim line As Line = New Line()
line.setLength(6.0)
Console.WriteLine("Length of line : {0}", line.getLength())
Console.ReadKey()
End Sub
End Class
When the above code is compiled and executed, it produces the following result:
Object is being created
Length of line : 6
Object is being deleted
Shared Members of a VB.Net Class
We can define class members as static using the Shared keyword. When we
declare a member of a class as Shared, it means no matter how many objects of
the class are created, there is only one copy of the member.
The keyword Shared implies that only one instance of the member exists for a
class. Shared variables are used for defining constants because their values can be
retrieved by invoking the class without creating an instance of it.
Shared variables can be initialized outside the member function or class
definition. You can also initialize Shared variables inside the class definition.
You can also declare a member function as Shared. Such functions can access only
Shared variables. The Shared functions exist even before the object is created.
The following example demonstrates the use of shared members:
Class StaticVar
Public Shared num As Integer
Public Sub count()
num = num + 1
End Sub
Public Shared Function getNum() As Integer
Return num
End Function
Shared Sub Main()
Dim s As StaticVar = New StaticVar()
s.count()
s.count()
s.count()
Console.WriteLine("Value of variable num: {0}", StaticVar.getNum())
Console.ReadKey()
End Sub
End Class
When the above code is compiled and executed, it produces the following result:
Value of variable num: 3
Inheritance
One of the most important concepts in object-oriented programming is that of
inheritance. Inheritance allows us to define a class in terms of another class which
makes it easier to create and maintain an application. This also provides an
opportunity to reuse the code functionality and fast implementation time.
When creating a class, instead of writing completely new data members and
member functions, the programmer can designate that the new class should
inherit the members of an existing class. This existing class is called the base class,
and the new class is referred to as the derived class.
Base & Derived Classes:
A class can be derived from more than one class or interface, which means that it
can inherit data and functions from multiple base classes or interfaces.
The syntax used in VB.Net for creating derived classes is as follows:
<access-specifier> Class <base_class>
...
End Class
Class <derived_class>: Inherits <base_class>
...
End Class
Consider a base class Shape and its derived class Rectangle:
' Base class
Class Shape
Protected width As Integer
Protected height As Integer
Public Sub setWidth(ByVal w As Integer)
width = w
End Sub
Public Sub setHeight(ByVal h As Integer)
height = h
End Sub
End Class
' Derived class
Class Rectangle : Inherits Shape
Public Function getArea() As Integer
Return (width * height)
End Function
End Class
Class RectangleTester
Shared Sub Main()
Dim rect As Rectangle = New Rectangle()
rect.setWidth(5)
rect.setHeight(7)
' Print the area of the object.
Console.WriteLine("Total area: {0}", rect.getArea())
Console.ReadKey()
End Sub
End Class
When the above code is compiled and executed, it produces the following result:
Total area: 35
Base Class Initialization
The derived class inherits the base class member variables and member methods.
Therefore, the super class object should be created before the subclass is created.
The super class or the base class is implicitly known as MyBase in VB.Net
The following program demonstrates this:
' Base class
Class Rectangle
Protected width As Double
Protected length As Double
Public Sub New(ByVal l As Double, ByVal w As Double)
length = l
width = w
End Sub
Public Function GetArea() As Double
Return (width * length)
End Function
Public Overridable Sub Display()
Console.WriteLine("Length: {0}", length)
Console.WriteLine("Width: {0}", width)
Console.WriteLine("Area: {0}", GetArea())
End Sub
'end class Rectangle
End Class
'Derived class
Class Tabletop : Inherits Rectangle
Private cost As Double
Public Sub New(ByVal l As Double, ByVal w As Double)
MyBase.New(l, w)
End Sub
Public Function GetCost() As Double
Dim cost As Double
cost = GetArea() * 70
Return cost
End Function
Public Overrides Sub Display()
MyBase.Display()
Console.WriteLine("Cost: {0}", GetCost())
End Sub
'end class Tabletop
End Class
Class RectangleTester
Shared Sub Main()
Dim t As Tabletop = New Tabletop(4.5, 7.5)
t.Display()
Console.ReadKey()
End Sub
End Class
When the above code is compiled and executed, it produces the following result:
Length: 4.5
Width: 7.5
Area: 33.75
Cost: 2362.5
UNIT-7 Namespaces
Namespaces-: Namespaces help you to create logical groups of related classes
and interfaces. Namespaces allow us to organize Classes so that they can be easily
accessed in other applications. Namespace is logical division of class, structure
and interface or way to organize your Visual Basic .NET code is through the use of
namespaces. They are a way of grouping type names and reducing the chance of
name collisions. The namespace with all the built-in functionality comes under
System namespace.
Collections of function method lasses’ data types are known as
name space. There are thousands of base classes are organized in much the same
way. a file system is organized into folder. These unit in which vb.net classes are
organized are classes are called name space.name space are control to the .net
environment as they provide a mechanism by which classes can be organized into
logical grouping making them easier to find and manage.name space in vb.net
are declared using a block structure name space.
Unit 8 Exception Handling
An exception is a problem that arises during the execution of a program. An
exception is a response to an exceptional circumstance that arises while a
program is running, such as an attempt to divide by zero. Exceptions provide a
way to transfer control from one part of a program to another. VB.Net
exception handling is built upon four keywords: Try, Catch, Finally and Throw.
Try: A Try block identifies a block of code for which particular exceptions
will be activated.
It’s follo ed y o e or ore Cat h lo ks. Catch: A program catches an exception with an exception handler at the
place in a program
where you want to handle the problem. The Catch keyword indicates the
catching of an exception.
Finally: The Finally block is used to execute a given set of statements,
whether an exception
is thrown or not thrown. For example, if you open a file, it must be closed
whether an exception is raised or not.
Throw: A program throws an exception when a problem shows up. This is
done using a Throw keyword.
Exception Classes in vb.Net Framework-: In the .Net Framework, exceptions are
represented by classes. The exception classes in .Net Framework are mainly
directly or indirectly derived from the System.Exception class. Some of the
exception classes derived from the System.Exception class are the
System.ApplicationException and System.SystemException classes.
The System.ApplicationException class supports exceptions generated by
application programs. So the exceptions defined by the programmers should
derive from this class.
The System.SystemException class is the base class for all predefined system
exception.
The following table provides some of the predefined exception classes derived
from the Sytem.SystemException class:
Exception Class Description
System.IO.IOException Handles I/O errors.
System.IndexOutOfRangeException Handles errors generated when a method
refers to an array index out of range.
System.ArrayTypeMismatchException Handles errors generated when type is
mismatched with the array type.
System.NullReferenceException Handles errors generated from deferencing
a null object.
System.DivideByZeroException Handles errors generated from dividing a
dividend with zero.
System.InvalidCastException Handles errors generated during
typecasting.
System.OutOfMemoryException Handles errors generated from insufficient
free memory.
System.StackOverflowException Handles errors generated from stack
overflow.
Handling Exceptions
VB.Net provides a structured solution to the exception handling problems in the
form of try and catch blocks. Using these blocks the core program statements are
separated from the error-handling statements.
These error handling blocks are implemented using the Try, Catch and Finally
keywords. Following is an example of throwing an exception when dividing by
zero condition occurs:
Module exceptionProg
Sub division(ByVal num1 As Integer, ByVal num2 As Integer)
Dim result As Integer
Try
result = num1 \ num2
Catch e As DivideByZeroException
Console.WriteLine("Exception caught: {0}", e)
Finally
Console.WriteLine("Result: {0}", result)
End Try
End Sub
Sub Main()
division(25, 0)
Console.ReadKey()
End Sub
End Module
When the above code is compiled and executed, it produces the following result:
Exception caught: System.DivideByZeroException: Attempted to divide by zero.
at ...
Result: 0
Creating User-Defined Exceptions
You can also define your own exception. User-defined exception classes are
derived from the ApplicationException class. The following example
demonstrates this:
Module exceptionProg
Public Class TempIsZeroException : Inherits ApplicationException
Public Sub New(ByVal message As String)
MyBase.New(message)
End Sub
End Class
Public Class Temperature
Dim temperature As Integer = 0
Sub showTemp()
If (temperature = 0) Then
Throw (New TempIsZeroException("Zero Temperature found"))
Else
Console.WriteLine("Temperature: {0}", temperature)
End If
End Sub
End Class
Sub Main()
Dim temp As Temperature = New Temperature()
Try
temp.showTemp()
Catch e As TempIsZeroException
Console.WriteLine("TempIsZeroException: {0}", e.Message)
End Try
Console.ReadKey()
End Sub
End Module
When the above code is compiled and executed, it produces the following result:
TempIsZeroException: Zero Temperature found
Throwing Objects
You can throw an object if it is either directly or indirectly derived from the
System.Exception class.
You can use a throw statement in the catch block to throw the present object as:
Throw [ expression ]
The following program demonstrates this:
Module exceptionProg
Sub Main()
Try
Throw New ApplicationException("A custom exception _
is being thrown here...")
Catch e As Exception
Console.WriteLine(e.Message)
Finally
Console.WriteLine("Now inside the Finally Block")
End Try
Console.ReadKey()
End Sub
End Module
When the above code is compiled and executed, it produces the following result:
A custom exception is being thrown here...
Now inside the Finally Block
Unit 9 Using System.Collections
ArrayList-: An array stores a fixed-size sequential collection of elements of the
same type. An array is used to store a collection of data, but it is often more
useful to think of an array as a collection of variables of the same type.
All arrays consist of contiguous memory locations. The lowest address
corresponds to the first element and the highest address to the last element.
The elements in an array can be stored and accessed by using the index of the
array. The following program demonstrates this:
Module arrayApl
Sub Main()
Dim n(10) As Integer ' n is an array of 11 integers '
Dim i, j As Integer
' initialize elements of array n '
For i = 0 To 10
n(i) = i + 100 ' set element at location i to i + 100
Next i
' output each array element's value '
For j = 0 To 10
Console.WriteLine("Element({0}) = {1}", j, n(j))
Next j
Console.ReadKey()
End Sub
End Module
Properties and Methods Used in ArrayList-:
Some common methods are:
1. Public Overridable Function Add (value As Object) As Integer: Adds an object
to the end of the ArrayList.
2. Public Overridable Sub AddRange (c As ICollection): Adds the elements of an
ICollection to the end of the ArrayList.
3. Public Overridable Sub Clear: Removes all elements from the ArrayList.
4. Public Overridable Function Contains (item As Object) As Boolean: Determines
whether an element is in the Array List.
5. Public Overridable Function GetRange (index As Integer, count As Integer) As
ArrayList: Returns an ArrayList which represents a subset of the elements in the
source ArrayList.
6. Public Overridable Function IndexOf (value As Object) As Integer: Returns the
zero-based index of the first occurrence of a value in the ArrayList or in a portion
of it.
7. Public Overridable Sub Insert (index As Integer, value As Object): Inserts an
element into the ArrayList at the specified index.
8. Public Overridable Sub InsertRange (index As Integer, c As ICollection):Inserts
the elements of a collection into the ArrayList at the specified index.
9. Public Overridable Sub Remove (obj As Object):Removes the first occurrence
of a specific object from the ArrayList.
10. Public Overridable Sub RemoveAt (index As Integer):Removes the element at
the specified index of the ArrayList.
Unit 10
Windows Programming
Q1 What is window form?
Ans-:Windows Forms is a framework located in the System.Windows.Forms.dll
assembly for building Windows applications in .NET based on a Graphical User
Interface (GUI). Any language that supports the Common Language Runtime (CLR)
can use Windows Forms. If you have programmed in Visual Basic (VB), you are
probably familiar with forms. In VB, all windows are forms. Controls are placed on
forms to develop GUI applications.
In addition, Windows Forms applications provide the following:
Simple and flexible property support
Common control support, including support for font and color dialogs
Support for Web Services
Data-aware controls using ADO.NET
ActiveX support
GDI+ (Graphical Device Interface +), a better and richer graphics library,
which supports
alpha blending, texture brushes, advanced transformations, and rich text
Metadata support
Q2Explain the controls in vb.net?
Ans-:The Control Class defines the base class for controls, which are components
with visual representation.
Control Tab Order-: Using the Tab key we can move focus from one control to
other. We can also customize this tab order. For this we make use of the Tab
Index property.there are many controls in vb.net.
1.Button Control-: 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.
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.
3. BackgroundImage Gets or sets the background image displayed in the control.
4. DialogResult Gets or sets a value that is returned to the parent form when the
button is clicked. This is used while creating dialog boxes.
5. ForeColor Gets or sets the foreground color of the control.
6. Image Gets or sets the image that is displayed on a button control.
7. Location Gets or sets the coordination of the upper-left corner of the control
relative to the upper-left corner of its container.
8. TabIndex Gets or sets the tab order of the control within container.
2.TextBox Control-: The TextBoxcontrol in Visual Basic 6.0 is replaced by the
Windows Forms TextBox control in Visual Basic .NET. The names of some
properties, methods, events, and constantszare different, and in some cases there
are differences in behavior. The following tables list Visual Basic 6.0 properties,
methods, and events and their Visual Basic .NET equivalents. Where applicable,
constants are indented beneath the property or method. All Visual Basic .NET
constants map to the System.Windows.Formsnamespace unless otherwise noted.
Text box controls allow entering text on a form at runtime.
TextBox Properties-:
1. AutoCompleteSource -: Gets or sets a value specifying the source of complete
strings used for automatic completion.
2.CharacterCasing -: Gets or sets whether the TextBox control modifies the case
of characters as they are typed.
3.Font -: Gets or sets the font of the text displayed by the control.
4.FontHeight-: Gets or sets the height of the font of the control.
5.Forecolor -: Gets or sets the foreground color of the control.
6.Lines -: Gets or sets the lines of text in a text box control.
7.Multiline-: Gets or sets a value indicating whether this is a multiline TextBox
control.
8.ScrollBars-: Gets or sets which scroll bars should appear in a multiline TextBox
control.
This property has values:
None
Horizontal
Vertical
Both
9.TabIndex-: Gets or sets the tab order of the control within its container.
10.Text-: Gets or sets the current text in the TextBox.
11.TextAlign-: Gets or sets how text is aligned in a TextBox control.
This property has values:
Left
Right
Center
3. RichTextBox Control-: A RichTextBox control is an advanced text box
that provides text editing and advanced formatting features including loading Rich
Text Format (RTF) files.We can create a RichTextBox control using a Forms
designer at design-time or using the RichTextBox class in code at run-time. To
create a RichTextBox control at design-time, you simply drag and drop a
RichTextBox control from Toolbox onto a Form in Visual Studio.
4.CheckBox Control-: CheckBoxes allow the user to make multiple
selections from a number of options. You can click a checkBox to select it and click
it again to deselect it.
5. ListBox-: The ListBox control displays a list of items from which we can
make a selection. We can select one or more than one of the items from the list.
Properties of list box-:
1. AllowSelection- Gets a value indicating whether the ListBox currently enables
selection of list items.
2. BorderStyle -Gets or sets the type of border drawn around the list box.
3. ColumnWidth -Gets of sets the width of columns in a multicolumn list box.
4. HorizontalExtent -Gets or sets the horizontal scrolling area of a list box.
6. ItemHeight -Gets or sets the height of an item in the list box.
7. Items - Gets the items of the list box.
8. MultiColumn - Gets or sets a value indicating whether the list box supports
multiple columns.
6. ComboBox-: The ComboBox control is used to display a drop-down list of
various items. It is a combination of a text box in which the user enters an item
and a drop-down list from which the user selects an item.
7. TreeView-: TreeView control is used to display hierarchical tree like
information such as a directory hierarchy.The top level in a tree view are root
nodes that can be expanded or collapsed if the nodes have child nodes
8. CheckedListBox-: A CheckedListBox control is a ListBox control with
CheckBox displayed in the left side where user can select a single or multiple
items. We can create a CheckedListBox control using a Forms designer at design-
time or using the CheckedListBox class in code at run-time (also known as
dynamically).
9.Panel-: The Panel control is a container control that is used to host a group of
similar child controls.
10. GroupBox-: Group Box is a container of other control. It displays a frame
around a group of controls. When you move the Group Box control, all of its
contained will also move.
GroupBox Properties
Auto Size: Gets or sets a value that indicates whether the GroupBox resizes
based on its contents.
BackColor: Gets or sets the background color for the control.
ForeColor:Change Fore Color of all control in side Group Box]
11. PictureBox Control-:
PictureBox control is used to display image. The images displayed can be any
format like Bitmap, JPEG, and GIF, PNG or any other image format files. The
PictureBox control is based on
the Control class.
12. StatusBar-: StatusBar control is not available in Toolbox of Visual Studio
2010. StatusStrip control replaces StatusBar in Visual Studio 2010. But for
backward compatibility support, StatusBar class is available in Windows Forms.
A StatusBar control is a combination of StatusBar panels where each panel can be
used to display different information.
13. RadioButton-: A radio button or option button is a type of graphical user
interface element that allows the user to choose only one of a predefined set of
options. When a user clicks on a radio button, it becomes checked, and all other
radio buttons with same group become unchecked.
Unit 11
Common Dialog Boxes
Common Dialog Boxes-: 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.
The RunDialog() function is automatically invoked when a user of a dialog box
calls its ShowDialog() function.
The ShowDialog method is used to display all the dialog box controls at run-time.
It returns a value of the type of DialogResult enumeration. The values of
DialogResult enumeration are:
Abort - returns DialogResult.Abort value, when user clicks an Abort button.
Cancel- returns DialogResult.Cancel, when user clicks a Cancel button.
Ignore - returns DialogResult.Ignore, when user clicks an Ignore button.
No - returns DialogResult.No, when user clicks a No button.
None - returns nothing and the dialog box continues running.
OK - returns DialogResult.OK, when user clicks an OK button
Retry - returns DialogResult.Retry , when user clicks an Retry button
Yes - returns DialogResult.Yes, when user clicks an Yes button
Unit 12 Q1 what is file and stream?
Ans-:a file is a collection of data and a