Presentation is loading. Please wait.

Presentation is loading. Please wait.

Project Structure and Tools 1120-Ch2.PPT

Similar presentations


Presentation on theme: "Project Structure and Tools 1120-Ch2.PPT"— Presentation transcript:

1 Project Structure and Tools 1120-Ch2.PPT
CNS 1120 Chapter 2 Introduction to Programming CNS 1120 Chapter 2 Project Structure and Tools 1120-Ch2.PPT Copyright © Don Kussee 1120-Ch2 #53

2 Structure of VB projects
CNS 1120 Chapter 2 Structure of VB projects l l l l l l l l Project 0 or 1 0+ 0+ Resource file 0+ Forms 1 1+ Class modules* 0+ Code modules General declarations section 1 Controls 0+ General sub procedures 0+ General declarations section 1+ General sub procedures Properties Event procedures * The structure of class modules has been omitted for clarity.

3 Structure of VB projects
CNS 1120 Chapter 2 Structure of VB projects l l l l l l l l The definition of what is included in the program. Project 0+ Forms Displayed “windows” 1 1+ 0+ General declarations section User interface object Controls General sub procedures 0+ 1+ Properties Event procedures Code Instructions to the computer

4 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Terms Project - all of the Forms, controls, code necessary for a program to run. Form - the screen we will design on, and the user will see. Controls or Objects - GUI objects attached to the form Expressions - code - the instructions that the computer will follow. Copyright © Don Kussee 1120-Ch2 #53

5 TOPE chart Task-Object-Event
CNS 1120 Chapter 2 TOPE chart Task-Object-Event Task Object Property Event Copyright © Don Kussee 1120-Ch2 #53

6 VB Programming Process
CNS 1120 Chapter 2 VB Programming Process Understand the user’s requirements Analyze - TOPE chart for inputs & outputs Develop the GUI forms to be used Place the controls on the forms Write code to hook the controls together Test and debug the program Create the executable program. Copyright © Don Kussee 1120-Ch2 #53

7 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Visual Basic Modes Design where most of our time will be spent Form, the tool bar and tool box are available Properties window is available Code window is available Run - where we will test & evaluate the program Break - where we can debug our problems Compile The program we will give to the user. Copyright © Don Kussee 1120-Ch2 #53

8 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 The VB environment l l l l l l l l Copyright © Don Kussee 1120-Ch2 #53

9 Form frm 53 Properties, 31 Events, 21 Methods
CNS 1120 Chapter 2 Form frm 53 Properties, 31 Events, 21 Methods

10 53 Properties Properties frm
CNS 1120 Chapter 2 53 Properties Properties frm Copyright © Don Kussee 1120-Ch2 #53

11 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Form Events 31 Events Copyright © Don Kussee 1120-Ch2 #53

12 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Form methods 21 Methods Circle, Line, Point Cls, Hide, Show, Refresh Popup menu Drag, DragOver Move left, [top, [width, [height]]] SetFocus, GotFocus, LostFocus Copyright © Don Kussee 1120-Ch2 #53

13 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Properties of Forms Caption - Name at the top of the form BackColor - Systems colors or Palette WindowState - 0 = Just like design(Default) 1 = Minimized, 2 = Maximized Name used in code also is default file name Form1.BackColor = vbRed Form1.Label2.Forecolor = vbRed Copyright © Don Kussee 1120-Ch2 #53

14 Objects, Classes, Controls
CNS 1120 Chapter 2 Objects, Classes, Controls Over 4000 different controls available - we will use about 10 Many special VBX on the internet NextPage Corp’s VBX is $ 5,000 VB assists in building of new Classes - ActiveX - VBX - OCX CNS 3200 includes these concepts Copyright © Don Kussee 1120-Ch2 #53

15 Controls, Objects, Classes
CNS 1120 Chapter 2 Controls, Objects, Classes Label Text Box Control Button Copyright © Don Kussee 1120-Ch2 #53

16 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Programs Series of steps for the computer to follow Computer can be told to do only 5 things Input Get data from outside Output - Supply data to outside Process - Add, Subtract, Multiply, etc Select Equal to, less than, between Loop Repeat some steps of a program Copyright © Don Kussee 1120-Ch2 #53

17 Controls, Objects, Classes
CNS 1120 Chapter 2 Controls, Objects, Classes Label output Text Box input Command Button trigger Pickup truck - Red Dodge V-10 long bed Bird - Gray - “chi-cog-o” - top-feather - walks Computer- 300 Mhertz- 64M RAM- 17” screen Copyright © Don Kussee 1120-Ch2 #53

18 Controls 7 general categories
CNS 1120 Chapter 2 Controls 7 general categories Trigger Timer, Command button Input TextBox, Combo, Scroll Output Label, Textbox, Image Organize Form, Frame Graphic Line, Circle Data Access Combo, Data Integration OLE Copyright © Don Kussee 1120-Ch2 #53

19 Primary Controls for Input…………... Output………...
CNS 1120 Chapter 2 Primary Controls for Input…………... Output………... Text box Command button MsgBox / InputBox Menu Check box Option buttons List / Combo box Scroll bars Text box MsgBox Label Image Picture Copyright © Don Kussee 1120-Ch2 #53

20 Controls - Object - Class
CNS 1120 Chapter 2 Controls - Object - Class Properties that can change it’s appearance Size, shape, location, look, color Events that it can respond to Click, mouse over, drag Methods - things it can do Move, Connect, Load, Update Copyright © Don Kussee 1120-Ch2 #53

21 Real world objects properties, events, methods
CNS 1120 Chapter 2 Real world objects properties, events, methods Cashier Woodpecker Grass Computer Student Professor Dog Vs Cat Airplane Jet ski Bicycle Bicycle rider Olympic Bicycle racer Car Duck Ostrich Duckbilled platypus Copyright © Don Kussee 1120-Ch2 #53

22 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 VB Tool Box Label tool Used to label other controls, and provide output. Copyright © Don Kussee 1120-Ch2 #53

23 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Label lbl 48 Properties Appearance & location 23 Events Change Click DblClick Load 10 Methods Move Refresh ZOrder Copyright © Don Kussee 1120-Ch2 #53

24 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Label Copyright © Don Kussee 1120-Ch2 #53

25 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Label properties Name - used in code procedures Caption - displayed on the form or control Enabled - does it work Visible - can you see it Usual event - None Copyright © Don Kussee 1120-Ch2 #53

26 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Command Button cmd 17 Events Cause an user event to occur - Click usually 24 Methods 32 Properties for each instantiation Appearance Size, Shape, Location, Colors, Font, Style Caption - The title on the button Picture property - an image on the button Copyright © Don Kussee 1120-Ch2 #53

27 Command Button properties
CNS 1120 Chapter 2 Command Button properties Name - used in code procedures Caption - displayed on the button Picture - displayed on the button Enabled - does it work Visible - can you see it Usual event - Click Copyright © Don Kussee 1120-Ch2 #53

28 CommandButton.Caption changed
CNS 1120 Chapter 2 CommandButton.Caption changed Copyright © Don Kussee 1120-Ch2 #53

29 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Events Copyright © Don Kussee 1120-Ch2 #53

30 Processing code for Command Button
CNS 1120 Chapter 2 Processing code for Command Button Note: header and indentation Copyright © Don Kussee 1120-Ch2 #53

31 Header required for every program
CNS 1120 Chapter 2 Header required for every program Rem ********************************* Rem *** Program name *** ‘ *** Programmers name *** ‘ *** Date of program *** ‘ *** Description of the program *** ‘ ******************************** Copyright © Don Kussee 1120-Ch2 #53

32 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Demo of design mode Add a control 3 ways Double click, Draw, Copy & Paste Delete control Change properties 3 ways F4 Type over Additional menu … Choice items Copyright © Don Kussee 1120-Ch2 #53

33 Procedure Vs Event programming
CNS 1120 Chapter 2 Procedure Vs Event programming Procedures ... the old way, it starts at the top and runs to the bottom every time - how a traffic light works, cars or no cars Event new way store clerks - demand The program waits, then reacts to some event. Reacts differently to different events. Event procedure is the detail code for the computer to follow Copyright © Don Kussee 1120-Ch2 #53

34 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Other VB Windows Form Layout Window Figure 2.25 Project Explorer Window Figure 2.26 Help Windows Figure Copyright © Don Kussee 1120-Ch2 #53

35 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Stopping Visual Basic Include an Exit key in every project Ctr + Break will stop processing Run menu Square Alt + R Gets run menu - choose E Copyright © Don Kussee 1120-Ch2 #53

36 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 The VB environment l l l l l l l l Copyright © Don Kussee 1120-Ch2 #53

37 Properties The currently selected control is named Command1 Object box
CNS 1120 Chapter 2 Properties The currently selected control is named Command1 The setting for Command1’s Caption property is Command1 Property list Object box

38 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Code window Procedure box Object box Code area Copyright © Don Kussee 1120-Ch2 #53

39 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Code Window Each procedure has an Object_Event Copyright © Don Kussee 1120-Ch2 #53

40 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 The VB environment l l l l l l l l Properties window Form window Menu bar Tool bar Toolbox Project window Code window Copyright © Don Kussee 1120-Ch2 #53

41 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Naming objects When projects get big (Project 2 Page 59 uses 17 labels) naming objects with meaningful names is very helpful when writing code and provides documentation. Not all objects need to be re-named All object names should use the three letter abbreviation of the object type Copyright © Don Kussee 1120-Ch2 #53

42 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Some primary controls Command button - allows user to cause event 32 properties Methods events cmd Form - The window that the user sees 52 properties Methods events frm Label - outputs information to the user 48 properties Methods events lbl Timer - an event based on time 7 properties Methods 1 event tmr Copyright © Don Kussee 1120-Ch2 #53

43 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Some primary controls Frame - groups controls into a group 34 properties Methods events fra Copyright © Don Kussee 1120-Ch2 #53

44 Command Button properties
CNS 1120 Chapter 2 Command Button properties 32 Properties Methods Events Name - used in code procedures Caption - displayed on the button Picture - displayed on the button Enabled - does it work Visible - can you see it Usual event - Click Copyright © Don Kussee 1120-Ch2 #53

45 Printing Visual Basic programs
CNS 1120 Chapter 2 Printing Visual Basic programs Copyright © Don Kussee 1120-Ch2 #53

46 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 File Names Win95 allows 256 characters Except only ~ ? * : But in DOS mode only 1st 6 letters are used There is an extension Form including controls and code FRM Changes to controls on the form FRX Project listing forms and others files .VBP Copyright © Don Kussee 1120-Ch2 #53

47 Win95 Standard File Extensions
CNS 1120 Chapter 2 Win95 Standard File Extensions VBP VB Project FRM VB Form VBX controls on form BAS VB Module CLS VB Class MDB MS Access TXT Generic text EXE Executable DAT Data LOG Recorded event COM Commands BAT Batch BIN Binary BAK Backup JPG Graphics SYS System Copyright © Don Kussee 1120-Ch2 #53

48 Saving Visual Basic Programs
CNS 1120 Chapter 2 Saving Visual Basic Programs Create a folder with a descriptive name In the folder, create a VB program Save the Form, Classes, Code, Resources Save the Project Save frequently Backup often Copyright © Don Kussee 1120-Ch2 #53

49 Saving Visual Basic Programs
CNS 1120 Chapter 2 Saving Visual Basic Programs Copyright © Don Kussee 1120-Ch2 #53

50 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 File type change Copyright © Don Kussee 1120-Ch2 #53

51 Expanded VP program parts
CNS 1120 Chapter 2 Expanded VP program parts Projects - grouping of forms & files & code One and only one project vbp Zero or more Forms - usually one frm modification of controls on the form .vbx Zero or more Code modules -often zero .bas Zero or more Class modules -often zero .cls Zero or more Resource files -often zero .res Copyright © Don Kussee 1120-Ch2 #53

52 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Assignments Lightening 1 Exchange Rate Café Don Lightening 2 Color choice Data types Copyright © Don Kussee 1120-Ch2 #53

53 Copyright © Don Kussee 1120-Ch2 #53
CNS 1120 Chapter 2 Computer Terms Syntax Semantic Keyword Code Control Object Properties Methods Events Run time error Syntax error Logical error Default value Form lbl Prefix cmd Prefix Empty string Copyright © Don Kussee 1120-Ch2 #53


Download ppt "Project Structure and Tools 1120-Ch2.PPT"

Similar presentations


Ads by Google