1. FEDT VB.NET
F R O N T E N D D E S I G N T O O L
U S I N G
V B . N E T
P R E S E N T A T I O N B Y :
A N K I T V E R M A
( I T D E P A R T M E N T )
A N K I T V E R M A A S S T . P R O F E S S O R
U N I T - 2
3. Elements Of IDE
Windows Form Designer
Add control to form, arrange them & add code.
Properties Window
Lists properties associated with control.
Solution Explorer
Display solution name, project name, form name, fields etc.
Tool Box
Provide controls like form, data, components, toolbar, menu etc.
Object Browser
Shows the members of object
28-11-2014 ANKIT VERMA 3
4. Elements Of IDE
Task List Window
List of errors in source code.
Server Explorer
Database connectivity, display tables, views, connections etc.
Dynamic Help
Context sensitive help.
Class View
Display Classes , methods, properties etc.
Code & Text Editor Window
Allow to enter and edit code
28-11-2014 ANKIT VERMA 4
6. Steps Of Writing Application In .NET
Start Visual Studio 2010
28-11-2014 ANKIT VERMA 6
7. Steps Of Writing Application In .NET
File New Project Select Language VB.NET
Choose Console or Window Application
28-11-2014 ANKIT VERMA 7
Provide
Project Name
10. Steps Of Writing Application In .NET
Write Code of program to be made.
Save Code by click File Save All
Press F5 & Run
28-11-2014 ANKIT VERMA 10
12. Project Templates
Window Application
Create application with window interface.
Class Library
Create classes to use in other application.
Console Application
Create command line application.
Window Control Library
Create control for applications.
Empty Project
Creating local application.
28-11-2014 ANKIT VERMA 12
14. VB Terms
Design Time
Environment where application being developed.
Run Time
Execution of application.
Forms
Basic element for creating user interface for application.
Controls
Manipulate information.
Properties
Control characteristics like color, caption, size etc.
28-11-2014 ANKIT VERMA 14
15. VB Terms
Methods
Actions that can be performed by object
Events
Action recognized by form or control.
Generated by user, OS or application.
28-11-2014 ANKIT VERMA 15
19. Similarities Between VB & VB.NET
Both Are Not Case Sensitive.
Both Support Windows & Web Based Application.
Both Are Provided With IntelliSense Feature.
28-11-2014 ANKIT VERMA 19
20. Difference Between VB & VB.NET
28-11-2014 ANKIT VERMA 20
VB .NET VB
Object Oriented Object Based
Data Type Declaration Required Not Strongly Typed
Structured Exception Handling Not Structured
Namespace To Organize Classes Not Supported
Automatic Garbage Collection Not Supported
ADO .NET For DB Connectivity DAO, RDO & ADO
Multithreading Not Supported
Console Applications Are Allowed Not Allowed
New Data Type Like Char, Short & Decimal Not Supported
Variable Can Declare In Same Line
Dim a As Integer = 10
Not Allowed
Object Data Type Variant Data Type
21. Difference Between VB & VB.NET
28-11-2014 ANKIT VERMA 21
VB .NET VB
Fixed Length String Not Allowed Allowed
Array Index Start With O Only Array Index Can Be Changed
Set Keyword Not Supported Set Keyword Used To Assign Object
Variables
Passing By Value Is Default For Calling
Procedure
Pass By Reference
Default Properties Of Controls Not
Allowed
Allowed
Return Keyword Used To Return Values name = return value Is Used
Optional Argument Must Be Specified
With Default Value
Not Necessary
23. Data Types Supported In VB.NET
Number Data Types
Byte
Short
Integer
Long
Single
Double
Decimal
28-11-2014 ANKIT VERMA 23
Character Data Type
Char
String
Other Data Type
Boolean
Date
User Defined Data Type
e.g. Structure
25. Variables
These Are Area In Memory Referred By Name Or
Identifier During Program Execution.
Dim a As Integer = 10
Dim b As Double = 14.01
Multiple Declaration Is Allowed.
Dim x , y As Integer
Constant
Value not change during execution of code.
Const a = 45
Identifier
Building block of programming language.
28-11-2014 ANKIT VERMA 25
26. Scope Of Variables
Block Scope
If block
Procedure Scope
Function
Module
Class variable accessed by all functions
Namespace Scope
Inside namespace
Shadowing
Same variable name in two procedures.
Scope only in module & accessed as FunctionName.Variable
28-11-2014 ANKIT VERMA 26
31. Assignment Operator
28-11-2014 ANKIT VERMA 31
OPRATOR OPERATION
= Assignment
+= Addition With Assignment
-= Subtraction With Assignment
*= Multiplication With Assignment
/= Floating Division With Assignment
= Integer Division With Assignment
^= Exponentiation With Assignment
<= Less Than Equal To
>= Greater Than Equal To
32. Logical Operator
28-11-2014 ANKIT VERMA 32
OPRATOR OPERATION
AND Return True, If Both Operands True
OR Return True, If One or Both Operands True
NOT Return True, If Reverse Logical Value Of Operand
XOR Return False, If Both Operands Either True Or False
34. Control Structure
Program Executes The Statement One After Other.
Control Structure Change The Flow OF Execution Of
These Statements.
Control Structure Are Classified Into Three Groups:
1) Decision Making / Conditional Statements
2) Looping
3) Other Statements
28-11-2014 ANKIT VERMA 34
36. 1) Decision Making / Conditional Statements
According To Value Of Variable, Control Flow Can Be
Changed For The Execution.
Two Statements Of This Category:
If – Else
Select Case
28-11-2014 ANKIT VERMA 36
37. 1) Decision Making : If - Else
Syntax:
If <condition> Then
[statement]
ElseIf <condition> Then
[statement]
Else
[statement]
EndIf
28-11-2014 ANKIT VERMA 37
40. 1) Decision Making : Select Case
Syntax:
Select Case <expression>
Case Value
[statement]
Case Value
[statement]
Case Else
[statement]
End Select
28-11-2014 ANKIT VERMA 40
43. 2) Looping
Execute Statements Repeatedly & Quickly.
Three Statements Of This Category:
Do Loop
While Loop
For Loop
28-11-2014 ANKIT VERMA 43
44. 2) Looping : Do Loop
Syntax:
Do While <condition>
[statement]
Loop
(OR)
Do Until <condition>
[statement]
Loop
28-11-2014 ANKIT VERMA 44
NOTE: Do Until loop executes only if statement is False.
45. 2) Looping : Do Loop
Example (Do While):
28-11-2014 ANKIT VERMA 45
46. 2) Looping : Do Loop
Example (Do Until):
28-11-2014 ANKIT VERMA 46
47. 2) Looping : While
Syntax:
While <condition>
[statement]
End While
28-11-2014 ANKIT VERMA 47
52. 3) Other Statements
Exit
Used to exit from loop
GOTO
Transfer the control to specified label
Stop
Return the program into break mode
End
Terminate the program
Return
Used in function to return the value to the calling method
28-11-2014 ANKIT VERMA 52
56. Data Structure In VB .NET
DS is a way of storing & organizing data in computer,
so that it can be used efficiently.
Different kind of DS are suited for different kind of
applications.
Some DS are highly specialized for specific tasks.
Various DS Are:
Array
Array Lists
Enumeration
28-11-2014 ANKIT VERMA 56
58. 1) Array
Array can hold collection of values of same type.
Element
Variable in an array is called Element.
Array has name & its elements can be accessed by
Index or Subscript.
Array can be single, double or multi dimension.
Lower Bound (LB) of all dimension array start with O.
Array is reference type.
Types of Array:
Static Array
Dynamic Array
28-11-2014 ANKIT VERMA 58
59. 1) Array : Static Array
Size of Static Array remain same even at runtime.
If Array is declared as Object type, we can store
different types of Data Type.
Syntax:
Dim a(5) As Integer
Dim b(3,5) As String
Dim c( ) As Single = {10.1 , 24.7}
Dim d(3) As Object
28-11-2014 ANKIT VERMA 59
61. 1) Array : Dynamic Array
Size of Dynamic Array changes during execution.
Used when you don’t know the size of Array.
Size of Array not provided during declaration.
Redim
After declaration no one change the data type .
Preserve
Preserve data without losing when dimension of array change.
28-11-2014 ANKIT VERMA 61
62. 1) Array : Dynamic Array
Syntax:
Dim a( ) As String
Redim a(5)
Dim b( , ) As Integer
Redim b(3,2)
ReDim Preserve b(3,4)
28-11-2014 ANKIT VERMA 62
63. 1) Array : Dynamic Array
Example:
28-11-2014 ANKIT VERMA 63
Value Not Lost After
Dimension Change
Because Of Preserve
64. 1) Array : Functions Of Array
Ubound (arrayname)
Determine upper bound of array.
Lbound (arrayname)
Determine lower bound of array.
28-11-2014 ANKIT VERMA 64
66. 2) Array Lists
Flexible Data Structure.
List can Grow & Shrink dynamically.
Contain list of values, on which we can perform
operations like Add, Delete etc.
28-11-2014 ANKIT VERMA 66
67. 2) Array Lists : Properties & Functions
Add
Add an item.
Insert
Insert an item at specified position.
Remove
Remove an item.
RemoveAt
Remove an item from specified position.
Sort
Sort items.
Count
Count the number of elements.
28-11-2014 ANKIT VERMA 67
72. 3) Enumerations
Enumeration is set of related constants that define a
value type, where each constant is known as member
of Enumeration.
Work for many constant of same type.
It set object properties & specify values that are passed
to methods.
Syntax:
[access modifier] Enum name
<Member List>
End Enum
28-11-2014 ANKIT VERMA 72
76. 1) MsgBox Function
Produce pop-up message box.
Prompt user to click on command button before he
can continues.
This function return the result values.
28-11-2014 ANKIT VERMA 76
77. 1) MsgBox Function
Msg=MsgBox(Prompt, Style Value, Title)
Prompt
It is message of 1024 (approx.) characters , be displayed to user.
Style
Denote the style & type of buttons to display in message box.
Values
MsgBoxStyle.YesNoCancel
MsgBoxStyle.YesNo
MsgBoxStyle.OkOnly (Default)
MsgBoxStyle.OkCancel
MsgBoxStyle.Exclamation
Title denotes the string displayed in title bar.
28-11-2014 ANKIT VERMA 77
78. 1) MsgBox Function
Result Values Can Be
MsgboxResult.ok
MsgboxResult.cancel
MsgboxResult.abort
MsgboxResult.retry
MsgboxResult.ignore
MsgboxResult.yes
MsgboxResult.no
28-11-2014 ANKIT VERMA 78
81. 2) InputBox Function
InputBox () function will display a message box where user
enter value or text.
Return value of function is string type.
Msg=InputBox(Prompt, Title, default_text, x-position,y-position)
Prompt
String expression displayed in dialog box.
Title
String expression displayed in title bar.
Default Text
Default response when user not provide input.
X, Y Position
Indicate the appearance if input box in screen.
28-11-2014 ANKIT VERMA 81
84. 3) Other Function
28-11-2014 ANKIT VERMA 84
FUNCTION USE
Strcomp Comparison for two strings
Lcase Convert String into Lower case
Ucase Convert String into Upper case
Rtrim Remove trailing spaces
Ltrim Remove leading spaces
Trim Remove both leading & trailing spaces
Mid Return specific number of character
Asc Return ASCII code of first letter in a string
Chr Return character of given ASCII code
Now Return current system date time
86. Comments
Comments are explanatory notes included in program
code following a single quotation mark (‘).
Single Line Comment
Provide single quotation mark (‘) before line.
Multiple Line Comment
Select multiple lines, whom you want to make comment.
Click Menu Edit Advance Comment Selection
or
Press Ctrl +K, Ctrl +C
28-11-2014 ANKIT VERMA 86
88. Procedures & Functions
They are group of related commands that perform
certain tasks and also called subprogram.
Used for repeated task.
Modular & easy to maintain.
Easy to debug
Any changes to code, you have to make changes only in
procedures, not every place of code.
Subprograms can be invoked from calling block.
Control transfer to procedure & after execution, return
back to calling procedure.
28-11-2014 ANKIT VERMA 88
89. Procedures & Functions
Argument which is passed can be variable, constant or
expression.
You can write the procedure in module, class module
and form module.
Procedure of class module support OOP concept.
There are four types of procedure:
Sub Procedure
Function Procedure
Event Procedure
Invoked according to action associated with controls.
Property Procedure
28-11-2014 ANKIT VERMA 89
91. 1) Sub Procedure
Sub Procedure can not return value.
Parentheses are not optional in VB .NET
Even no parameters still procedure enclosed using
empty parentheses.
For calling, procedure name followed by parameters.
Syntax:
[Access Specifier] sub Name (Arg As DataType, …)
<Statement>
End Sub
28-11-2014 ANKIT VERMA 91
95. 2) Function Procedure
Return a value back to calling program.
Function can return values in two ways:
Using Return statement
Assign value to function name, like VB
If return data type is not mentioned, Object type will
be default one.
Function can also called same as procedure.
Syntax:
[Access Specifier] Function Name (Arg As DataType, …) [As DataType]
<Statement>
End Sub
28-11-2014 ANKIT VERMA 95
98. 3) Event Procedure
Events are actions associate with object.
Foam Load
Button Click
Mouse Click
Events can be raised by user action, by system or by
code itself.
User can write code to handle events, called event
handling procedures.
By these procedures, we can call the sub or function
procedures, called implicitly.
28-11-2014 ANKIT VERMA 98
100. Passing Parameter
Code in a procedure needs some information about the
state of the program to do the job.
These are passed to procedures as arguments.
There are two ways:
Pass By Value
Pass By Reference
28-11-2014 ANKIT VERMA 100
101. 1) Pass By Value
Default mode of passing arguments.
Copy of argument is passed to the procedure.
Any change in value never affect the original variable,
but only affect the copy.
ByVal keyword is used explicitly, otherwise compiler
automatically inserts this keyword.
Syntax:
Public Sub disp (ByVal a As Integer)
<statements>
End Sub
28-11-2014 ANKIT VERMA 101
102. 2) Pass By Reference
Address of argument is passed to procedure.
Procedure can change its value permanently.
Procedure have full access to argument.
ByRef keyword is used.
Syntax:
Public Sub disp (ByRef a As Integer)
<statements>
End Sub
28-11-2014 ANKIT VERMA 102
103. 3) Optional Argument
Optional argument is passed to provide some optional
argument with default value.
If we not pass value of argument, default value will be
substituted.
28-11-2014 ANKIT VERMA 103
104. 4) Named Argument
Argument data type can’t be changed when we pass the
arguments to procedure.
Using Named Argument, we can pass the value by
providing Argument Name followed by colon, an equal
sign and argument value.
Arguments can be passed in any order.
28-11-2014 ANKIT VERMA 104
106. Creating & Using Namespace
Namespace allows you to create your own namespaces
for holding classes.
By default classes are created in root namespace that is
based on your project name.
Syntax:
Namespace <namespace name>
Class <class name>
Members
End Class
End Namespace
28-11-2014 ANKIT VERMA 106
107. Creating & Using Namespace
Creating:
Using
28-11-2014 ANKIT VERMA 107
108. THANKYOU
P R E S E N T A T I O N B Y :
A N K I T V E R M A
( I T D E P A R T M E N T )
DOUBTS
A N K I T V E R M A A S S T . P R O F E S S O R