Upload
john-drew
View
213
Download
0
Embed Size (px)
Citation preview
8/3/2019 Prelim Lecture
1/18
Goyonan, Mary Jean R. Page 1 of18
BT601M
Overview of Microsoft .Net
MS .Net Platform MS .Net Framework The .Net Framework Components Visual Basic .Net Enhancements
MS. Net Platform
- This is used to simplify Web development by providing all the tools and techniques that aprogrammer need to build distributed applications
- It also provides new ways of creating Windows applications
MS .Net
- This is a set of technologies designed to transform the internet into a full-scale distributed computingplatform
- .Net Platform Provides:o A language-independent, consistent programming model across all tiers of an applicationo Seamless interoperability between technologieso Easy migration from existing technologieso Full support for the Internets platform-neutral, standards-based technologies, including
Hypertext Transfer Protocol (HTTP), Extensive Markup Language (XML), and Simple Object
Access Protocol (SOAP).
Technologies in the .Net Platform
1. .Net Framework is based on a common language runtime (CLR), which provides sets of servicesbuilt in any Visual Studio .Net languages. It also has Framework Class Library (FCL), which provides
predefined types or classes that can be used in programming applications
2. .Net Building Block Services are programmable services that can be implemented on a computerconnected in the local server only (offline) or accessed through the internet (online).
3. Visual Studio .Net provides advanced features, high-level development environment for buildingapplications on the .net framework. It provides new features for Windows-based applications. Itprovides also the technologies to simplify the design and development of Web services and
applications
4. .Net Enterprise Serversa. MS SQL Server 2000b. MS BizTalk Server 2000c. MS Host Integration Server 2000
8/3/2019 Prelim Lecture
2/18
Goyonan, Mary Jean R. Page 2 of18
BT601M
d. MS Exchange 2000 Enterprise Servere. MS Application Center 2000f. MS Internet Security and Acceleration Server 2000
.Net Framework- A set of technologies that are integral part of the .NET Platform- Provides the basic building block to develop Windows Application, Web Applications and Web
Services
- Provides the services necessary to develop and deploy applications
Languages in the .NET Framework
1. MS Visual Basic .NET provides substantial language innovations over previous versions of VB2. MS Visual C# - designed for the .NET Platform and is the first modern component-oriented language
in the C and C++ family. It can be embedded in ASP.NET pages.
3. Managed Extensions C++ - a managed minimal extension to the C++ language4. MS Visual J# .Net for Java developers who want to build and develop applications and services for
the .NET Framework
5. Third-Party Languages includes COBOL, Pascal, Perl, Phyton, and SmallTalk
Components/Elements of .NET Framework
- Common Language Runtimeo Responsible for loading code and managing the execution of that codeo Managed Environment
Environment provides common services automatically and makes the developmentprocess easier
- .NET Framework Class Libraryo A consistent, object-oriented library of pre-packed functionalityo Exposes features of the runtime and provides other high-level services that every
programmer needs through namespace Namespace-organize the object of an assembly into a structure that is easy to
understand.
System System.Net System.Reflection System.IO
8/3/2019 Prelim Lecture
3/18
Goyonan, Mary Jean R. Page 3 of18
BT601M
System.Security - System.Text System.Threading System.Diagnostics System.Runtime.InteropServices System.Configuration System.Collections
- ADO.NET: Data and XMLo Next generation of ActiveX Data Object technologyo Provides improved support for the disconnected programming modelo ADO.NET classes used to handle data and support XML at runtime:
System.Data namespace System.Xml namespace
- ASP.NET: Web Forms and Serviceso A programming framework built on the CLR for writing Web-based applications
ASP.Net Web Forms ASP.NET Web Services
o Common ASP.NET classes System.Web System.Web.Services System.Web.UI
- User Interface for Windowso User Interface for Windows
Windows applications can provide more powerful user interfaces than ever byusing:
System.Windows.Forms System.Drawing
VB .NET Enhancements
- Major language Enhancementso Enhanced object-oriented supporto Structured Exception handling
- Full access to the .NET Frameworko New threading optionso Garbage collection
8/3/2019 Prelim Lecture
4/18
Goyonan, Mary Jean R. Page 4 of18
BT601M
- Enhanced Web developmento Create Web developmento Create Web Services quickly
The Visual Studio .Net IDE
Differences between VB.Net and VB6 IDEo There is one IDE for all .NET projectso Solutions can contain multiple programming languageo The IDE is customizable through My Profile o The IDE has a built-in Internet browser
VB .NET Templates
Template Use this template to create
Windows Applications Standard Windows-based application
Class Library Class libraries that provides similar functionality to MS Active X DLL
Windows Control
Library
User-defined Windows control projects
Web Control Library User-defined Web controls that can be reused on the Web
Console Application Console application that will run from a command line
Windows Service Windows services that will run continuously regardless of whether a user is
logged on or not.
Analyzing Projects
- What follows are files contained in every VB.Net Project:o Solution files (.s | n, . suo)o Project files (.vbproj)o Local project items (.vb)o Web project item (.aspx, .asmx, .asax)
Creating Visual Basic .Net Projectso Assemblies
One or more files that make up a Visual Studio Application Key concept in .Net development Serve as building block for all .NET applications
8/3/2019 Prelim Lecture
5/18
Goyonan, Mary Jean R. Page 5 of18
BT601M
o Namespaces Used in .NET Framework assemblies Organize classes, interface and modules into a structure that is easy to understand
Setting Project Referenceso
Application Property Settings: Assembly name Root namespace Application type Startup object Assembly Information
o Compile Property Settings: Build output path Option explicit Option strict
Using Development Environment Featureso IDE Features
Solution Explorer Object Browser Server Explorer Task List Dynamic Help
o Form Window Where the controls that make up the user interface are placed
o Code Window Where the codes for forms, events and methods are written, displayed and modified
o Toolbox Contains the objects and controls that can be added to Windows Forms
o Component Tray Where non-visual components that do not appear at runtime are stored
o Properties Windows
Where properties of an object selected at design time are modifiedo Auto Hide
hides windows form the main IDE Click the Auto Hide button on the toolbar to toggle Auto Hide on and off
o Tabbed Documents This mode adds a tab to the top of the main window for each open document or file Click on the tab that represents the document to switch between open documents
8/3/2019 Prelim Lecture
6/18
Goyonan, Mary Jean R. Page 6 of18
BT601M
o Multiple Documents MDI Multiple Document Interface Display multiple documents simultaneously To work in an MDI environment
Tools > Options
Click Multiple documents on the Window layout section Click ok
o Dockable windows All windows within the IDE can be docked to any edge of the IDE by dragging them
to any location
Solution Explorer
- Displays project hierarchy, project references, project items and any subfolders thatcontain project items
- Show all Files mode- Manipulating projects
o Drag-and-drop editingo Context menus
Debugging Applicationso Setting Breakpointso Debugging codes
Designing VB.NET Application
- Steps in Creating a program in VB.Neto Create the interfaceo Set propertieso Write the code
Visual Basic .NET Languages
- Data Types, Variables and Array- Operators, Conditionals, and Loops- Procedures (Sub and Function)- Exemption Handling
8/3/2019 Prelim Lecture
7/18
Goyonan, Mary Jean R. Page 7 of18
BT601M
Data Types
- The data types of the variable or constant indicates what type of information will be stored in theallocated memory space.
- Each type has:o
A nameo A size
Indicates the number of bytes each object of this occupies in memoryType Size (in
bytes)
Description
Byte 1 Unsigned (values 0-255)
Char 2 Unicode characters (0-65,535 unsigned)
Date 8 Midnight 1/1/0001 through 11:59:59 12/21/9999
Decimal 16
Fixed-precision numbers up to 28 digits and the position of the decimal point;
typically used in financial calculations; requires the suffix m or M.
Double 3 Double-precision floating-point numbers; holds the values from approximately
+/-5.0 * 10-324to approximately +/-1.8 * 10308 with 15-16 significant figures.
Boolean 2 True or False
Integer 4 Integer values between 2,147,483,648 and 2,147,483,647
Long 8 Integers ranging from 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Short 2 Integer values -32,768 to 32,767
Single 4 Floating-point numbers; holds the values from approximately +/-1.5 * 10-45 to
approximate +/-3.4 * 1038 with 7 significant figures.String Varies A sequence of Unicode characters
Data Type Changes
VB6 VB .NET
Integer Short
Long Integer
(None) Long
Variant Not supported: use Decimal
Currency Not supported: use Decimal
Date No longer stored as a double
String (fixed length) Not supported
8/3/2019 Prelim Lecture
8/18
Goyonan, Mary Jean R. Page 8 of18
BT601M
CType
- Used to convert any value from data type to another.- This is similar to CStr and CInt in VB6- Syntax:-
CType (expression, typename)
Variables
- This is an object that can hold a value- It also names storage location with a type- Declaring and Initializing Variable- Syntax:- Dim Identifier [as DataType] = value/expression
DataType Default Value
Numbers 0
Boolean FALSE
Date 01/01/0001 12:00:00 AM
Object Nothing
String Nothing
Variable Scope
- Can be declared aso Privateo Publico Statico Sharedo Protectedo Friend
Constant
-This is like a variable that can store a value, but it cannot be changed while the program runs.
- Declaring constant
Constconstantname [as type] = expression
8/3/2019 Prelim Lecture
9/18
Goyonan, Mary Jean R. Page 9 of18
BT601M
Arrays
- This is a memory location that is used to store multiple values- It is an indexed collection of objects all of the same type- It is the simplest collection of objects in VB.Net
Types of Arrays
- One-dimensional arrayso With element identified by a single subscript
- Multidimensional Arrayso Allows you to create rows of elements, one above the other
Rectangular all the rows are the same length Jagged each rows has different length
- Declaring an Arrayso Declaring one-dimensional array
Dim array_name (Num_elements) [as element_type]
o Dynamic Arrays The size of a dynamic array can vary during the execution of the program Creating dynamic array
Use DIM statement, declaring it with empty parenthesisDim arr_name() as string
o ReDim Statement Use ReDim statement to specify or change the size of one or more dimensions of an
array that has already been declared.
Synatx:ReDimaarr_name(100)
Operators
- Used to assign or retrieve values based on expressions or statements
Types of Operators:
1. Arithmetic Operatorsa. ^ exponentiationb. * multiplicationc. / divisiond. \ integer division
8/3/2019 Prelim Lecture
10/18
Goyonan, Mary Jean R. Page 10 of18
BT601M
e. Mod Modulusf. + additiong. - subtractionh. >> performs an arithmetic right shift on a bit patterni.
= greater than or equale. = equal tof. not equalg. Is true if 2 object references refer to the same objecth. Like performs string pattern matching
4. The String Concatenation operatorsa. &b. +
5. Logical/Bitwise Operatorsa. Andb. Notc. ORd.
Xor exclusive or
e. AndAlso short-circuited And operatorf. OrElse short-circuited Or operators
6. Other operatorsa. AddressOf
Gets the address of a procedureb. GetType
8/3/2019 Prelim Lecture
11/18
Goyonan, Mary Jean R. Page 11 of18
BT601M
Gets information about a type
Operator Precedence
- Predefined order to which the operations occurred in an expression at once is evaluated.-
Arithmetic and Concatenationo Exponentiation (^)o Negation (-)o Multiplication and Division (*, /)o Integer Division (\)o Modulus arithmetic (Mod)o Addition and Subtraction (+, -)o String Concatenation (&)o Arithmetic Bit shift ()
- Comparisono Equality (=)o Inequality ()o Less than, greater than ()o Greater than or equal to (>=)o Lesser than or equal to (
8/3/2019 Prelim Lecture
12/18
Goyonan, Mary Jean R. Page 12 of18
BT601M
.
.
.
End if
oSelect Statement
Two or more conditions to check Syntax:
Select Case test-expression
Case expression-1
[statement-1]
Case expression-2
[statement-2]
.
.
.
End select
Control Statement
- Also known as looping, repeat action(s) for a number of times or until a specified condition isachieved.
- Includeso For/Nexto For Each/Nexto Do/Loopo While/Endo With statements
ForNext Statement
- When the number of passes to be made through the loop is known.- Syntax:
For index [as datatype] = start to end[statement]
[exit for]
[statement]
Next [index]
8/3/2019 Prelim Lecture
13/18
Goyonan, Mary Jean R. Page 13 of18
BT601M
For EachNext Loop
- Used to loop over elements in an array or other type of collection of elements- Syntax:
For each element [as datatype] in group
[statement][exit for]
[statement]
Next [element]
DoLoop
- Used to keep executing VB statements while or until its condition is true.- Syntax:
Do [while | Until] condition do
[statement] [statement]
Exit do exit do
[statement] [statement]
Loop loop [while | Until] condition
Whileend While
- Used to repeat a set of statements as long as the condition is true.- Syntax:
While condition
[statement]
End while
With Statement
- Used to make a VB object the default object for a set of enclosed VB Statement- Syntax:
With object
[statement]
End with
Procedures
- It contains all of the executable code in the application. It gives the ability to logically group code thatwill perform certain task.
- This is created within a class or a module.- Always be called from the same class or module in which it is created.
8/3/2019 Prelim Lecture
14/18
Goyonan, Mary Jean R. Page 14 of18
BT601M
Access Modifier
- Determine the scope within which a procedure can be called.- Valid Access Modifiers below:
o Publico
Privateo Sharedo Protectedo Friendo Protected Friend
Advantages:
- Reusable- Easier to debug and maintain
Types of Procedures
1. Sub Procedureso Performs specific tasks and do not return a value to a calling statement.o Syntax:
[][{overloads | Overrides | Overridable | NotOverridable | MustOverride | Shadows |
Shared }]
[{ Public | Protected | Friend | Protected Friend | Private }]
Sub Subname[(arglist)]
[statement]
[exit sub]
[statement]
End sub
o The syntax for calling a Sub Procedure is:[ Call ] ([Arguments list])
2. Function Procedureo Performs specific tasks and return a value to a calling statement.o it perform a specific task and are created in classes and moduleso it can return a value
8/3/2019 Prelim Lecture
15/18
Goyonan, Mary Jean R. Page 15 of18
BT601M
o syntax:[][{overloads | Overrides | Overridable | NotOverridable | MustOverride | Shadows |
Shared }]
[{ Public | Protected | Friend | Protected Friend | Private }]
FunctionFunctionName[(arglist)][as type]
[statement]
[exitfunction]
[statement]
End Function
o The syntax for calling a Function Procedure is:ReturnValue = ([Arguments list])
Built-in Functions
- These are very useful in easing your development.- It is also important to know that the MS. VB namespace has functions that can use in applications as
well.
- Microsoft.VisualBasic.Conversiono ErrorToStringo Fix and Into Hexo Octo Stro Val
- Microsoft.VisualBasic.DateAndTimeo DateAddo DateDiffo DateParto DateSerialo
DateStringo DateValueo Dayo Houro Minuteo Montho MonthName
o Nowo Secondo TimeOfDayo Timero
TimeSerialo TimeStringo TimeValueo Todayo WeekDayo WeekDayNameo Year
8/3/2019 Prelim Lecture
16/18
Goyonan, Mary Jean R. Page 16 of18
BT601M
- Microsoft.VisualBasic.Stringo ASCo Chro Filtero
FormatNumbero FormatPercento GetCharo InStro InStrRevo Joino LCaseo Left
o Leno LSet, RSeto LTrim, Trim, RTrimo
Mido Replaceo Spaceo Splito StrCompo StrConvo StrReverseo UCase
Exception Handling
- 2 ways of handling exceptions in vb.net1. Unstructured centers on the On Error GoTo statement. It be handled anywhere in the
code using the On Error GoTo Statement.
2. Structure centers on the Try/Catch statement. It restricts error handling to a specifiedcode blocks.
- Disadvantages of Unstructured exceptiono Code is difficult to read, debug, and maintaino Easy to overlook errors
Types of Errors
1. Syntax Error the reason for these error are misspelled keywords or variable.2. Logic Errors error occurs when code does not act as expected because of a flaw in the logic that is
applied
3. Runtime Errors These errors occurs when a program is asked to do something that it cannot do.
Unstructured Exception Handling
- Revolves around the On Error GoTostatementOn Error {GoTo [line |0|-1| Resume Next}
GoTo Line calls the error-handling codes that starts at the line specified at line.
8/3/2019 Prelim Lecture
17/18
Goyonan, Mary Jean R. Page 17 of18
BT601M
GoTo 0 disables the enabled error handler in the current procedure GoTo -1 - disables the enabled error handler in the current procedure Resume Next specifies that when an exception occurs, execution skips over the statement
that caused the problem and goes to the statement immediately following.
Exceptions Number and Description
- A built-in error object named Err has a Numberproperty that determines an errors number - When testing the program, use Err.Numberto determine the number of errors that may occur and
use those numbers to handle errors in different ways.
Resume Statement
- This is used to resume program execution in unstructured exception handling- Syntax:
Resume [0] - Resumes execution with the statement that caused the error
Resume Nextresumes execution with the statement after the one that caused the error.
Resume Line resumes execution at line, a line number or label that specifies where to resume
execution.
Structured Exception Handling
- Centers on the Try/Catch statement- Advantages
o Supported by multiple languageso Allows creating protective blocks of codeso Allows filtering of exceptions similar to SELECT Case Statement using the Catch blocko Allows nested handlingo Code is easier to read and, debug, and maintain.
TryCatchFinally
- This is a structured exception handling implemented in VB.Net.- Syntax:
Try
[ trystatement]
[ catch [ exception1 [as type1]] [ when expression 1]
8/3/2019 Prelim Lecture
18/18
Goyonan, Mary Jean R. Page 18 of18
BT601M
catchStatement1
[exit try]
[ catch [ exception2 [as type2]] [ when expression 2]
catchStatement2
[exit try].
.
.
[ catch [ exceptionn [as typen]] [ when expressionn1]
catchStatementn
[exit try]
[Finally
[finally statements]]
System.Exception Class
- Provides information about a particular exception.- Properties and Methods of System.Exception
o Message used to retrieve informationo Source used to retrieve the name of applicationo StackTrace used to retrieve the stack trace of the exception as stringo InnerException used to navigate to multiple nested exceptionso HelpLink used to retrieve the appropriate Help file, URN, or URL for the exceptiono ToString used to return the fully qualified name of the exception, the exception message,
the name of the inner exception and the stack trace.
--------------------------------------------------------PRELIMINARY PERIOD
GOOD LUCK!
-------------------------------------------------------