Sie sind auf Seite 1von 18

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 a programmer need to build distributed applications MS .Net This is a set of technologies designed to transform the internet into a full-scale distributed computing platform .Net Platform Provides: o o o o A language-independent, consistent programming model across all tiers of an application Seamless interoperability between technologies Easy migration from existing technologies 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 services built 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 computer connected in the local server only (offline) or accessed through the internet (online). 3. Visual Studio .Net provides advanced features, high-level development environment for building applications on the .net framework. It provides new features for Windows-based applications. It provides also the technologies to simplify the design and development of Web services and applications 4. .Net Enterprise Servers a. b. c. MS SQL Server 2000 MS BizTalk Server 2000 MS Host Integration Server 2000 It also provides new ways of creating Windows applications

Goyonan, Mary Jean R. BT601M

Page 1 of 18

d. e. f.

MS Exchange 2000 Enterprise Server MS Application Center 2000 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. 2. 3. 4. 5. MS Visual Basic .NET provides substantial language innovations over previous versions of VB 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. Managed Extensions C++ - a managed minimal extension to the C++ language MS Visual J# .Net for Java developers who want to build and develop applications and services for the .NET Framework Third-Party Languages includes COBOL, Pascal, Perl, Phyton, and SmallTalk

Components/Elements of .NET Framework Common Language Runtime o o Responsible for loading code and managing the execution of that code Managed Environment Environment provides common services automatically and makes the development process easier .NET Framework Class Library o o A consistent, object-oriented library of pre-packed functionality 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

Goyonan, Mary Jean R. BT601M

Page 2 of 18

o o o

System.Security System.Text System.Threading System.Diagnostics System.Runtime.InteropServices System.Configuration System.Collections

ADO.NET: Data and XML Next generation of ActiveX Data Object technology Provides improved support for the disconnected programming model ADO.NET classes used to handle data and support XML at runtime: System.Data namespace System.Xml namespace

ASP.NET: Web Forms and Services o A programming framework built on the CLR for writing Web-based applications o ASP.Net Web Forms ASP.NET Web Services System.Web System.Web.Services System.Web.UI

Common ASP.NET classes

User Interface for Windows o User Interface for Windows Windows applications can provide more powerful user interfaces than ever by using: System.Windows.Forms System.Drawing

VB .NET Enhancements Major language Enhancements o o Enhanced object-oriented support Structured Exception handling New threading options Garbage collection

Full access to the .NET Framework o o

Goyonan, Mary Jean R. BT601M

Page 3 of 18

Enhanced Web development o o Create Web development Create Web Services quickly

The Visual Studio .Net IDE Differences between VB.Net and VB6 IDE o o o o There is one IDE for all .NET projects Solutions can contain multiple programming language The IDE is customizable through My Profile The IDE has a built-in Internet browser

VB .NET Templates Template Windows Applications Class Library Windows Control Library Web Control Library Console Application Windows Service User-defined Web controls that can be reused on the Web Console application that will run from a command line 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 o o o Solution files (.s | n, . suo) Project files (.vbproj) Local project items (.vb) Web project item (.aspx, .asmx, .asax) Use this template to create Standard Windows-based application Class libraries that provides similar functionality to MS Active X DLL User-defined Windows control projects

Creating Visual Basic .Net Projects o 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

Goyonan, Mary Jean R. BT601M

Page 4 of 18

Namespaces Used in .NET Framework assemblies Organize classes, interface and modules into a structure that is easy to understand

Setting Project References o Application Property Settings: o Assembly name Root namespace Application type Startup object Assembly Information Build output path Option explicit Option strict

Compile Property Settings:

Using Development Environment Features o IDE Features o o o Toolbox o o o o Contains the objects and controls that can be added to Windows Forms Where non-visual components that do not appear at runtime are stored Where properties of an object selected at design time are modified hides windows form the main IDE Click the Auto Hide button on the toolbar to toggle Auto Hide on and off 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 Component Tray Properties Windows Auto Hide Solution Explorer Object Browser Server Explorer Task List Dynamic Help Where the controls that make up the user interface are placed Where the codes for forms, events and methods are written, displayed and modified

Form Window Code Window

Tabbed Documents

Goyonan, Mary Jean R. BT601M

Page 5 of 18

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

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 that contain project items Show all Files mode Manipulating projects o o Drag-and-drop editing Context menus

Debugging Applications o o Setting Breakpoints Debugging codes

Designing VB.NET Application Steps in Creating a program in VB.Net o o o Create the interface Set properties Write the code

Visual Basic .NET Languages Data Types, Variables and Array Operators, Conditionals, and Loops Procedures (Sub and Function) Exemption Handling

Goyonan, Mary Jean R. BT601M

Page 6 of 18

Data Types The data types of the variable or constant indicates what type of information will be stored in the allocated memory space. Each type has: o o Type Byte Char Date Decimal Double Boolean Integer Long Short Single String A name A size Size (in bytes) 1 2 8 16 3 2 4 8 2 4 Varies Unsigned (values 0-255) Unicode characters (0-65,535 unsigned) Midnight 1/1/0001 through 11:59:59 12/21/9999 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-precision floating-point numbers; holds the values from approximately +/-5.0 * 10-324to approximately +/-1.8 * 10308 with 15-16 significant figures. True or False Integer values between 2,147,483,648 and 2,147,483,647 Integers ranging from 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Integer values -32,768 to 32,767 Floating-point numbers; holds the values from approximately +/-1.5 * 10-45 to approximate +/-3.4 * 1038 with 7 significant figures. A sequence of Unicode characters Indicates the number of bytes each object of this occupies in memory Description

Data Type Changes VB6 Integer Long (None) Variant Currency Date String (fixed length) VB .NET Short Integer Long Not supported: use Decimal Not supported: use Decimal No longer stored as a double Not supported

Goyonan, Mary Jean R. BT601M

Page 7 of 18

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 Default Value 0 01/01/0001 12:00:00 AM Nothing Nothing

DataType Numbers Boolean FALSE Date Object String Variable Scope -

Can be declared as o o o o o o Private Public Static Shared Protected 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

Goyonan, Mary Jean R. BT601M

Page 8 of 18

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 arrays o With element identified by a single subscript 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 Multidimensional Arrays o

Declaring an Arrays o 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 o Use DIM statement, declaring it with empty parenthesis Dim arr_name() as string 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 Operators a. b. c. d. ^ * / \ exponentiation multiplication division integer division

Goyonan, Mary Jean R. BT601M

Page 9 of 18

e. f. g. h. i. 2. a. b. c. d. e. f. g. h. 3. a. b. c. d. e. f. g. h. 4. a. b. 5. a. b. c. d. e. f. 6. a. b.

Mod + >> << = ^= *= /= \= += -= &= < <= > >= = <> Is Like & + And Not OR Xor OrElse

Modulus addition subtraction performs an arithmetic right shift on a bit pattern performs an arithmetic left shift on a bit pattern assignment exponentiation followed by assignment multiplication followed by assignment division followed by assignment integer division followed by assignment addition followed by assignment subtraction followed by assignment string concatenation followed by assignment less than Lesser than or equal greater than greater than or equal equal to not equal true if 2 object references refer to the same object performs string pattern matching

Assignment Operators

Comparison Operators

The String Concatenation operators

Logical/Bitwise Operators

exclusive or short-circuited Or operators

AndAlsoshort-circuited And operator

Other operators AddressOf Gets the address of a procedure GetType

Goyonan, Mary Jean R. BT601M

Page 10 of 18

Gets information about a type Operator Precedence Predefined order to which the operations occurred in an expression at once is evaluated. Arithmetic and Concatenation o o o o o o o o Exponentiation (^) Negation (-) Multiplication and Division (*, /) Integer Division (\) Modulus arithmetic (Mod) Addition and Subtraction (+, -) String Concatenation (&) Arithmetic Bit shift (<<,>>) Equality (=) Inequality (<>) Less than, greater than (<,>) Greater than or equal to (>=) Lesser than or equal to (<=) Like Is Negation (Not) Conjunction (And, AndAlso) Disjunction (Or, OrElse, Xor)

Comparison o o o o o o o Logical o o o

Conditional Statement Also known as branching statements Allows a programmer to make decisions and take different paths in the code o If statement Allow a programmer to use comparison and logical operators to examine data and make decisions based on the results. Syntax: If condition then [statements] Elseif condition then [statements]

Goyonan, Mary Jean R. BT601M

Page 11 of 18

. . . End if o Select 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 is achieved. Includes o o o o o For/Next For Each/Next Do/Loop While/End 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]

Goyonan, Mary Jean R. BT601M

Page 12 of 18

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 [statement] Exit do [statement] Loop 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 that will 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. do [statement] exit do [statement] loop [while | Until] condition

Goyonan, Mary Jean R. BT601M

Page 13 of 18

Access Modifier Determine the scope within which a procedure can be called. Valid Access Modifiers below: o o o o o o Advantages: Reusable Easier to debug and maintain Public Private Shared Protected Friend Protected Friend

Types of Procedures 1. Sub Procedures o o Performs specific tasks and do not return a value to a calling statement. Syntax: [<attrlist>][{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 ] <procedureName> ([Arguments list]) 2. Function Procedure o o o Performs specific tasks and return a value to a calling statement. it perform a specific task and are created in classes and modules it can return a value

Goyonan, Mary Jean R. BT601M

Page 14 of 18

syntax: [<attrlist>][{overloads | Overrides | Overridable | NotOverridable | MustOverride | Shadows | Shared }] [{ Public | Protected | Friend | Protected Friend | Private }] FunctionFunctionName[(arglist)][as type] [statement] [exitfunction] [statement] End Function

The syntax for calling a Function Procedure is: ReturnValue = <FunctionName>([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.Conversion o o o o o o ErrorToString Fix and Int Hex Oct Str Val DateAdd DateDiff DatePart DateSerial DateString DateValue Day Hour Minute Month MonthName o o o o o o o o o o o Now Second TimeOfDay Timer TimeSerial TimeString TimeValue Today WeekDay WeekDayName Year

Microsoft.VisualBasic.DateAndTime o o o o o o o o o o o

Goyonan, Mary Jean R. BT601M

Page 15 of 18

Microsoft.VisualBasic.String o o o o o o o o o o o ASC Chr Filter FormatNumber FormatPercent GetChar InStr InStrRev Join LCase Left o o o o o o o o o o o Len LSet, RSet LTrim, Trim, RTrim Mid Replace Space Split StrComp StrConv StrReverse UCase

Exception Handling 2 ways of handling exceptions in vb.net 1. 2. Unstructured centers on the On Error GoTo statement. It be handled anywhere in the code using the On Error GoTo Statement. Structure centers on the Try/Catch statement. It restricts error handling to a specified code blocks. Disadvantages of Unstructured exception o o Types of Errors 1. 2. 3. Syntax Error the reason for these error are misspelled keywords or variable. Logic Errors error occurs when code does not act as expected because of a flaw in the logic that is applied Runtime Errors These errors occurs when a program is asked to do something that it cannot do. Code is difficult to read, debug, and maintain Easy to overlook errors

Unstructured Exception Handling Revolves around the On Error GoTostatement On Error {GoTo [line |0|-1| Resume Next} GoTo Line calls the error-handling codes that starts at the line specified at line.

Goyonan, Mary Jean R. BT601M

Page 16 of 18

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 Number property that determines an errors number When testing the program, use Err.Number to 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 Next resumes 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 o o o o Supported by multiple languages Allows creating protective blocks of codes Allows filtering of exceptions similar to SELECT Case Statement using the Catch block Allows nested handling 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]

Goyonan, Mary Jean R. BT601M

Page 17 of 18

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 o o o o o Message used to retrieve information Source used to retrieve the name of application StackTrace used to retrieve the stack trace of the exception as string InnerException used to navigate to multiple nested exceptions HelpLink used to retrieve the appropriate Help file, URN, or URL for the exception 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! -------------------------------------------------------

Goyonan, Mary Jean R. BT601M

Page 18 of 18

Das könnte Ihnen auch gefallen