Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © Don Kussee 1120-Ch2 #531 CNS 1120 Chapter 2 Project Structure and Tools 1120-Ch2.PPT.

Similar presentations


Presentation on theme: "Copyright © Don Kussee 1120-Ch2 #531 CNS 1120 Chapter 2 Project Structure and Tools 1120-Ch2.PPT."— Presentation transcript:

1 Copyright © Don Kussee 1120-Ch2 #531 CNS 1120 Chapter 2 Project Structure and Tools 1120-Ch2.PPT

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

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

4 Copyright © Don Kussee 1120-Ch2 #534 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.

5 Copyright © Don Kussee 1120-Ch2 #535 TOPE chart Task-Object-Event Task Object Property Event

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

7 Copyright © Don Kussee 1120-Ch2 #537 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.

8 Copyright © Don Kussee 1120-Ch2 #538 The VB environment 

9 Form frm 53 Properties, 31 Events, 21 Methods

10 Copyright © Don Kussee 1120-Ch2 #5310 53 Properties Properties frm

11 Copyright © Don Kussee 1120-Ch2 #5311 Form Events 31 Events

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

13 Copyright © Don Kussee 1120-Ch2 #5313 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

14 Copyright © Don Kussee 1120-Ch2 #5314 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

15 Copyright © Don Kussee 1120-Ch2 #5315 Controls, Objects, Classes Text Box Control Button Label

16 Copyright © Don Kussee 1120-Ch2 #5316 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

17 Copyright © Don Kussee 1120-Ch2 #5317 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

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

19 Copyright © Don Kussee 1120-Ch2 #5319 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

20 Copyright © Don Kussee 1120-Ch2 #5320 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

21 Copyright © Don Kussee 1120-Ch2 #5321 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

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

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

24 Copyright © Don Kussee 1120-Ch2 #5324 Label

25 Copyright © Don Kussee 1120-Ch2 #5325 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

26 Copyright © Don Kussee 1120-Ch2 #5326 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

27 Copyright © Don Kussee 1120-Ch2 #5327 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

28 Copyright © Don Kussee 1120-Ch2 #5328 CommandButton.Caption changed

29 Copyright © Don Kussee 1120-Ch2 #5329 Events

30 Copyright © Don Kussee 1120-Ch2 #5330 Processing code for Command Button Note: header and indentation

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

32 Copyright © Don Kussee 1120-Ch2 #5332 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

33 Copyright © Don Kussee 1120-Ch2 #5333 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

34 Copyright © Don Kussee 1120-Ch2 #5334 Other VB Windows Form Layout Window Figure 2.25 Project Explorer Window Figure 2.26 Help Windows Figure 2.29 - 32

35 Copyright © Don Kussee 1120-Ch2 #5335 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

36 Copyright © Don Kussee 1120-Ch2 #5336 The VB environment 

37 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 #5338 Code window Procedure box Object box Code area

39 Copyright © Don Kussee 1120-Ch2 #5339 Code Window Each procedure has an Object_Event

40 Copyright © Don Kussee 1120-Ch2 #5340 The VB environment  Menu barTool barToolboxCode windowForm windowProperties windowProject window

41 Copyright © Don Kussee 1120-Ch2 #5341 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

42 Copyright © Don Kussee 1120-Ch2 #5342 Some primary controls Command button - allows user to cause event –32 properties 24 Methods 17 events cmd Form - The window that the user sees –52 properties 21 Methods 31 events frm Label - outputs information to the user –48 properties 10 Methods 18 events lbl Timer - an event based on time –7 properties 0 Methods 1 event tmr

43 Copyright © Don Kussee 1120-Ch2 #5343 Some primary controls Frame - groups controls into a group –34 properties 6 Methods 13 events fra

44 Copyright © Don Kussee 1120-Ch2 #5344 Command Button properties 32 Properties 24 Methods 17 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

45 Copyright © Don Kussee 1120-Ch2 #5345 Printing Visual Basic programs

46 Copyright © Don Kussee 1120-Ch2 #5346 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

47 Copyright © Don Kussee 1120-Ch2 #5347 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

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

49 Copyright © Don Kussee 1120-Ch2 #5349 Saving Visual Basic Programs

50 Copyright © Don Kussee 1120-Ch2 #5350 File type change

51 Copyright © Don Kussee 1120-Ch2 #5351 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

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

53 Copyright © Don Kussee 1120-Ch2 #5353 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


Download ppt "Copyright © Don Kussee 1120-Ch2 #531 CNS 1120 Chapter 2 Project Structure and Tools 1120-Ch2.PPT."

Similar presentations


Ads by Google