1 / 91

Illuminating Computer Science CCIT 4-6Sep aast/en/colleges/ccit/cs4hs/

Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/. Introduction to Programming Concepts. Visual Basic: an Introduction. Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/. Objectives.

elmo-wyatt
Download Presentation

Illuminating Computer Science CCIT 4-6Sep aast/en/colleges/ccit/cs4hs/

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. Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/

  2. Introduction to Programming Concepts Visual Basic: an Introduction Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/

  3. Objectives • The audience should be familiar with the Visual Basic Environment. • The audience should be able to build simple Visual Basic Applications. • The audience should learn the precedence rules for writing equations. • The audience should be able to write programs using control structures

  4. Performing a Task on the Computer • Determine Output • Identify Input • Determine process necessary to turn given Input into desired Output

  5. Problem-solving approach like algebra class • How fast is a car traveling if it goes 50 miles in 2 hours? • Output: a number giving the rate of speed in Km per hour • Input: the distance and time the car has traveled • Process: rate = distance/time

  6. Pictorial representation of the problem solving process

  7. Program Planning Tips • Always have a plan before trying to write a program • The more complicated the problem, the more complex the plan must be • Planning and testing before coding saves time coding

  8. Simplified Program development cycle 1. Analyze: Define the problem. 2. Design: Plan the solution to the problem. 3. Choose the interface: Select the objects (text boxes, buttons, etc.).

  9. Program development cycle continued 4. Code: Translate the algorithm into a programming language. Try to avoid jumping straight to this step, which can result in a sloppy solution! 5. Test and debug: Locate and remove any errors in the program. 6. Complete the documentation: Organize all the material that describes the program.

  10. What is Visual Basic? • High Level 4th Generation Programming Language • Object and Event Driven • Visual - Windows Based • Integrated Development Environment or IDE

  11. What is VB Used For? • Most Popular Programming Language • Stand alone programs • Applets that can be run on many different kinds of computers • Customized specialized Applications • E- Commerce • Web based shopping forms and inquiries • User friendly Interface to applications

  12. Also enables user to click on buttons to initiate processing steps. Allows user to use a mouse to click on boxes for text entry. Example Order Entry Screen l l l l l l Used by a computer equipment retail outlet to record data regarding customer orders.

  13. Generations of Computer Languages • 1st - Machine language - 0110 0011 1000 • 2nd - Procedure-oriented languages • FORTRAN - 1954 for scientists and engineers • COBOL - 1959 for business applications • C - 1972 - for UNIX operating systems • 3rd - Object-oriented languages • 4th - Event-driven languages - i.e.VB • 5th - Natural languages i.e. English

  14. Compiler Vs Interpreter • Higher Languages are translated to Machine Language by: • Interpreter • Translates instructions to machine code line-by-line. • BASIC, Quick Basic, Visual Basic • Compiler • Translates the entire program to machine code before running it. • Fortran, C, C++, Visual Basic is also a compiler

  15. What are the Objects in VB? • Pre-programmed Code for: • Command Buttons • Labels • Pictures • Text Boxes • Have both data and procedures wrapped together

  16. What are the Events? • Visual Basic “watches” what the user does • A user activity is called an event • Events include mouse clicks and moves, menu selections, button presses, etc. • Sections of code are only executed in response to an event

  17. What is the Integrated Development Environment (IDE)? Project Explorer (Lists forms) Toolbox (Objects) Form Designer Window Properties Code Editor Forms Layout Window

  18. Visual Basic Environment GUI (Graphical User Interface) - forms and windows that the user sees Property - a characteristic or attribute of an object such as color and size Event - a user action such as clicking a button Code Editor window - editor specially designed to help you when writing code

  19. Visual Basic Environment • Components of the VB design environment (Form view)

  20. Visual Basic Environment • Components of the VB design environment (Code view)

  21. The Code Editor Window Object List Box Procedure List Box Full Module View button Auto List Members

  22. The Code Editor Window Help window Syntax error in Red Procedure view button Error message box

  23. VB Environment: Project Window • The Project Window can be used to navigate between the code and form window for each form / window a project has

  24. VB Environment: Menu Bar • Title bar Menu Bar Toolbar • The Menu Bar consists of 3 elements the • Title Bar, which holds the name of application, default if Microsoft Visual Basic [design] • Menu Bar, this is the link to Visual Basics menu facilities, each menu option drops down into sub-menus • Toolbar, contains icons which give access to the more commonly used commands (which are also available through the menu bar)

  25. VB Environment: Properties Window • Used to set how a control looks andbehaves • Holds its default values

  26. VB Environment: Control Toolbox Picture Text Box Command Button Option/Radio Button List Box Vertical Scroll Bar Drive List Box File List Box Line Data Control Pointer Label Group Frame Check Box Combo Box Horizontal Scroll Bar Timer Directory List Box Shape Image OLE

  27. VB Environment: Context Sensitive Help • Context sensitive help is very useful • Select the item control that you want help on • Press the F1 key F1

  28. The File Menu Project commands Make executable commands Most recent project list Exit command

  29. New Project Open Project Add Project Remove Project Save Project Save Project As Save Component Save Component As Print Print Setup The File Menu

  30. The File Menu Template -particular pattern for a project or a project element; start a project from a template saves time Existing tab - displays VB projects Recent tab - displays most recently accessed projects Project Groups - a collection of several projects

  31. Building Your First Application • There are three primary steps in building a Visual Project: • Place (or draw) controls on the form. • Assign properties to the controls. • Write event procedures for the controls.

  32. Project Files vbp extension = Visual Basic Project • file that tracks all components frm extension = Form file • separate file for each form frx extension = Binary form file • cannot be read by humans vbwextension = Visual Basic workspace

  33. Starting Visual Basic

  34. Choosing Project Type

  35. Placing Controls on the Form: Image

  36. Assigning Properties to Controls

  37. Adding an Image

  38. Browse for an Image

  39. Image Displayed

  40. Buttons and Text Boxes

  41. Changing the Form Title

  42. Writing the Code (Events)

  43. Writing the Code (Events)

  44. Running the Application

  45. Running the Application

  46. More Complex Structures

  47. Syntax Boxes • Syntax for a Visual Basic statement is shown in a syntax box • Reserved words are shown in bold • Programmer named words are shown in italics

  48. The Sub Statement Private Subcontrolname_eventname( ) Statements End Sub Where Private is the default procedure type Sub indicates beginning of procedure controlname is name of associated control _ (underscore) required separator eventname is name of corresponding event ( ) set of parentheses is required End Sub indicates end of a procedure

  49. The Sub Statement Example Private Sub cmdCalcTriangle_Click Dim Base As Single Dim Height As Single Dim Height As Single Area = 1 / 2 * (Base * Height) End Sub

  50. Declarations, Variables, and Constants Variable - a uniquely named storage location that contains data that changes during program execution Constant - a uniquely named storage locations that contains data that does not change during program execution

More Related