Presentation is loading. Please wait.

Presentation is loading. Please wait.

.NET Framework.NET Framework class libraries: A large set of classes that forms the basis for objects that can be used programmatically. –Programming in.

Similar presentations


Presentation on theme: ".NET Framework.NET Framework class libraries: A large set of classes that forms the basis for objects that can be used programmatically. –Programming in."— Presentation transcript:

1 .NET Framework.NET Framework class libraries: A large set of classes that forms the basis for objects that can be used programmatically. –Programming in the.NET Framework means making use of the classes exposed by the Framework, building your own classes on top of these and manipulating the resulting objects. Creating Internet applications and Windows applications

2 Class and Object A class is a blueprint from which objects are made. Every object created from a class is an instance of the class. Properties and methods: An object’s interface consists of properties and methods. A property is an attribute associated with an object, while a method is an action that the object can carry out.

3 Object-Oriented Concepts Encapsulation: The implementation of a class – in other words, what goes on inside the class – is separate from the class’s interface. Inheritance: The process in which a new class can be based on an existing class, and will inherit that class’s interface and behaviors. Polymorphism: The concept of using a single name for different behaviors. –Overloaded function: Two functions have the same name but different input arguments.

4 VB.NET is Object-Oriented Everything from the simplest data types provided by VB to the complex windows is a class. –Ex: Dim iNum as Integer iNum=10 Debug.WriteLine (“The number is: “ & iNum.ToString)

5 XML and.NET.NET Framework uses XML for: –Configuration –Cache dataset –Web services –Web form layouts –Etc. XML data combined with schema are becoming increasingly important.

6 XML Example 1-34567-04-01 John Smith Peter Chen David Chao $45.00 This is a grerat book 1-34567-04-02 Adam Smith $25.00 This is a second grerat book

7 Visual Studio.NET It is the development environment for creating applications based on the.NET Framework. It supports VB, C#, and C++. Demo: –Start page: MyProfile –Starting project: Project types, name and location, –Solutions and projects, renaming a project –Configure start up environment: Tools/Option –View/Solution, View/Class, Project/Add Windows Form, Project/Add New Item –Form, Code view, File Properties and Object properties

8 Introduction to Visual Basic.Net Event-driven programming –The interface for a VB program consists of one or more forms, containing one or more controls (screen objects). –Form and control has a number of events that it can respond to. Typical events include clicking a mouse button, type a character on the keyboard, changing a value, etc. –Event procedure

9 Text Box Properties: –AutoSize, BorderStyle, CauseValidation, Enabled, Locked, Multiline, PasswordChar, ReadOnly, ScrollBar, TabIndex, Text, Visible, etc. Properties can be set at the design time or at the run time using codes. To refer to a property: –ControlName.PropertyName –Ex. TextBox1.Text

10 Demo Num1 Num2 Sum = Control properties Event: Click, MouseMove, FormLoad, etc. Event procedures Sum: textBox3.text=CStr(CDbl(textBox1.text)+CDbl(textBox2.text)) Or (CDbl(textBox1.text)+CDbl(textBox2.text)).toString

11 VB Projects A VB project consists of several files. Always create a project folder and keep all project files in the folder. –Solution file –Project file –Form file –Modules –Class file –Etc.

12 Configure VB Project Project property page –General – Build: Option Explicit – Imports Debug –Debug/Windows

13 Introductory VB Topics Declaring variables: Option Explicit –DIM, PUBLIC, PRIVATE, STATIC, CONST –Boolean, Integer, Long, Single, Double, Date –Ex: DIM dblIntRate As Double –Ex: Dim X As Integer, Y As Single –Ex: Dim A, B, C As String –Ex: Dim X AS Integer = 25 –Ex: CONST Maximum As Integer = 100

14 Object Reference Declare object variales: –Dim varName As Classname –varName = New Classname() –Or: Dim varName As New Classname() Dereferencing objects: –varName = Nothing

15 Variable Scope Block-level scope: declared within a block of code terminated by an end, loop or next statement. –If city = “Rome” then Dim message as string = “the city is in Italy” MsgBox(message) –End if Procedural-level scope: declared in a procedure Class-level, module-level scope: declared in a class or module but outside any procedure with either Dim or Private keyword. Project-level scope: a class or module variable declared with the Public keyword.

16 Data Conversion –Functions: CStr, Ccur, CDbl, Cint, CLng, CSng, Val, etc. –Type class’s methods: toString

17 Arithmetic and String Operators +, -, *, /. \, ^ String Concatenation: & Compound operator: : X= X+1 or X +=1

18 IF Statement IF condition THEN statements [ELSEIF condition-n THEN [elseifstatements] [ELSE [elsestatements]]] End If

19 Select Case Structure SELECT CASE testexpression [CASE expressionlist-n [Statements] [CASE ELSE [elsestatements] END SELECT

20 Select Case Example SELECT CASE temperature CASE <40 Text1.text=“cold” CASE 40 to 60 Text1.text=“cool” CASE 60 to 80 Text1.text=“warm” CASE ELSE Text1.text=“Hot” End Select

21 Loop FOR index – start TO end [STEP step] [statements] [EXIT FOR] NEXT index DO [{WHILE| UNTIL} condition] [statements] [EXIT DO] LOOP

22 Do While/Do Until Private Sub Command1_Click() Dim counter As Integer counter = 0 Do While counter <= 5 Debug.Print counter counter = counter + 1 Loop Text1.Text = counter End Sub Private Sub Command2_Click() Dim counter As Integer counter = 0 Do Until counter > 5 Debug.Print counter counter = counter + 1 Loop Text1.Text = counter End Sub

23 With … End With With TextBox1.Height = 250.Width = 600.Text = “Hello” End With Convenient shorthand to execute a series of statements on a single object. Within the block, the reference to the object is implicit and need not be written.

24 Procedures. Sub procedure: Sub SubName(Arguments) … End Sub –To call a sub procedure SUB1 CALL SUB1(Argument1, Argument2, …) Or SUB1(Argument1, Argument2, …)

25 Function Private Function tax(salary) As Double tax = salary * 0.1 End Function –Or Private Function tax(salary) Return salary * 0.1 End Function

26 Call by Reference Call by Value ByRef –Default –The address of the item is passed. Any changes made to the passing variable are made to the variable itself. ByVal –Only the variable’s value is passed.

27 ByRef, ByVal example Private Sub Command1_Click() Dim myStr As String myStr = TextBox1.Text ChangeTextRef (myStr) TextBox1.Text = myStr End Sub Private Sub ChangeTextRef(ByRef strInput As String) strInput = "New Text" End Sub


Download ppt ".NET Framework.NET Framework class libraries: A large set of classes that forms the basis for objects that can be used programmatically. –Programming in."

Similar presentations


Ads by Google