1 / 17

Programming Languages—Procedural, Event Driven, and Object Oriented

Programming Languages—Procedural, Event Driven, and Object Oriented. Procedural—Cobol, Fortran, Basic Program specifies exact sequence of all operations. Event-Driven Programming(VB 6.0 and previous) Contain some elements of object-oriented programming, but not all

shawna
Download Presentation

Programming Languages—Procedural, Event Driven, and Object Oriented

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Languages—Procedural, Event Driven, and Object Oriented • Procedural—Cobol, Fortran, Basic • Program specifies exact sequence of all operations. • Event-Driven Programming(VB 6.0 and previous) • Contain some elements of object-oriented programming, but not all • Object-Oriented Programming (OOP) (VB .NET) • User controls sequence • Click event • Double Click event • Change event

  2. The Object Model In VB, you will work with objects that have properties, methods, and events. Each object is based on a class. • Objects equate to Nouns. • Forms are windows. • Controls are components contained inside a form. • Properties equate to Adjectives. • Color or size of a Form • Methods are like Verbs. • Typical methods include Close, Show and Clear

  3. Object Model Continued • Events occur when the user takes action. • User clicks a button, User moves a form • Classes are templates used to create a new object. • Classes contain the definition of all available properties, methods, and events. • Each new object created is based on a class. • Creating three new buttons makes each button a instance of the Button class.

  4. An Object Model Analogy • Class = automobile • Properties of automobile class= make, model, color, engine, year • Object = Each individual auto is an object. • Object is also an Instance of the automobile class. • Methods = start, stop, speedup, slowdown • Events of automobile class = Turn Wheel, Press Brake

  5. Visual Studio .NET • Included in Visual Studio .NET 2010 • Visual Basic • C# (C sharp) • J# (J sharp) • F# (F sharp) • .NET 3.5 Framework (Base Class Library) • Common Language Runtime (CLR) • All languages compile into a common machine language: MSIL (Microsoft Intermediate Language) • Visual Studio .NET Editions: Express, Standard, Professional, Ultimate • Get your own Professional Edition at www.dreamspark.com

  6. Visual Basic Creates Graphical User Interfaces You can create both windows and web apps. Text boxes Check box Radio buttons Message box Buttons Picture box Label

  7. Visual Studio Environment The Visual Studio environment is where you create and test your projects. In Visual Studio, it is called an Integrated Development Environment (IDE) consisting of various tools including: • Form Designer • Editor for entering and modifying code • Compiler • Debugger • Object Browser • Help Facility

  8. IDE Main Window Solution Explorer Document window Properties window

  9. The Tool Box You select objects from the toolbox (controls) to create your user interface. By default, the toolbox is auto-hidden on the far left of the screen, but you can change that.

  10. VB Application Files • Solution File— usually one solution file equals one project: HelloWorld.sln • Solution User Options File: HelloWorld.suo • Form Files: HelloForm.vb • Resource File for the Form: HelloForm.resx • Form Designer:HelloForm.Designer.vb • Project User Options File: HelloWorld.vbproj.user Once a project is run, several more files are created by the system. The only file that is opened directly is the solution file.

  11. Writing Visual Basic Projects There is a three-step process when writing a Visual Basic application: • set up the user interface, • define the properties • create the code.

  12. Your First Visual Basic.NET Example Create an application that displays a form with a field for entering your name. Two buttons are also displayed on the form: • when the first button is clicked, display a label that says: Hello, name. • when the second button is clicked, exit the program

  13. Creating the Code • While the project is running, the user can perform actions. • Each action by the user causes an event to occur. • Write code for the events you care about. • Code is written as event procedures, usually as an object method: Example: Me.Close() Methods always have parentheses; properties never do. • VB will ignore events for which you do not write code.

  14. Naming Conventions in Your Code • Use meaningful names: orderForm, not form1 • Have a set of standards and always follow them!!! • No spaces, punctuation marks, or reserved words • Some example conventions: • Pascal Casing: MessageLabel, ExitButton • Camel Casing: messageLabel, exitButton • Industry: lblMessage, btnExit

  15. Documenting Your Code: The Remark Statement • Also known as a comment, it is used for documentation; every procedure should begin with a remark statement providing explanation. • It is non-executable • Automatically colored green in code editor • Begins with an apostrophe ( ' ) • On a separate line from executable code • At the right end of a line of executable code 'Display the Hello World message.

  16. Debugging Finding and Fixing Errors • Syntax Errors • Breaks VB’s rules for punctuation, format, or spelling • Smart editor finds most syntax errors, compiler finds the rest. • The editor identifies a syntax error with a squiggly blue line and you can point to an error to pop up the error message. • Youcan display the Error List window and line numbers in the source code to help locate the error lines. • Run-Time Errors • Statements that fail to execute, such as impossible arithmetic operations • Logic Errors • Project runs, but produces incorrect results.

  17. Visual Basic Help • Help displays in a separate browser window. • Microsoft Developer’s Network (MSDN) is the primary source of help documentation. • Access MSDN at http://msdn.microsoft.com • Context-sensitive help is also available by pressing the F1 key.

More Related