Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to Programming and Visual Basic .NET

Similar presentations


Presentation on theme: "Intro to Programming and Visual Basic .NET"— Presentation transcript:

1 Intro to Programming and Visual Basic .NET
Chapter 1 Chapter 1

2 Program Set of instructions a computer follows to perform a task
Examples Calculate gross pay, taxes, and net pay Print past-due notices to credit card holders Drop the lowest homework assignment score Chapter 1

3 Computer Programs Used in most industries Accounting Human Resources
Education Aviation Marketing Chapter 1

4 Program Acquisition Shrink-Wrap Software In-house Development
Very available Lower cost Standardized, not customizable In-house Development Higher cost Customizable to specific needs Outsourcing Customizable Chapter 1

5 Methods of Programming
Procedural Statements executed by the computer, one after another, in sequential order from start to termination of a program Typical of text-based terminal User responds to program Object-Oriented GUI interface consisting of a set of objects Program responds to user Chapter 1

6 Procedural Program Example
Display onscreen message: "How many hours did you work?" Allow the user to enter the number of hours worked Once the user enters a number, store it in memory Display onscreen message: “What is your hourly pay rate?" Allow the user to enter an hourly pay rate Multiply the two numbers stored in memory and store the result in memory Display a message on the screen that shows the gross pay. The message must include the result of the calculation performed in step 7 Chapter 1

7 Procedural Program Example
How many hours did you work? 10 What is your hourly pay rate? 15 Your gross pay is $150.00 C>_ Chapter 1

8 Object-Oriented Programming (OOP)
Centered on object creation. Object: element containing data & actions Examples Form (window) object Label (descriptions) object Text Box (data entry) object Button (event driven) object Attributes (Properties) Text property (e.g., Hourly Pay Rate) Size (Height & Width) Location (Vertical & Horizontal Position) Chapter 1

9 Event-Driven Programming
Responds to events Action or occurrence that takes place in the program. User Action Examples Click or double-click a button Press a key on the keyboard System Occurrences Examples Timer Sits idle until an event occurs—again program responds to user (or system). Chapter 1

10 Events Button Object (Control) responds to a Click event.
Text Box Object (Control) responds to data entry, which is a TextChanged event. Chapter 1

11 Event Procedure Algorithm that executes when the event occurs.
Not triggered until event occurs. Chapter 1

12 Algorithm* Formula or set of steps for solving a particular problem
Characteristics: Unambiguous Well-defined Clear Fewest steps possible Terminal *Adapted from webopedia.com’s definition. Chapter 1

13 Algorithm Example *Example for algorithm definition on webopedia.com.
Chapter 1

14 Pseudocode* Outline of a program No real formatting or syntax rules
Cross between human language and programming language. Human readable Basis for algorithm development No real programming language skills needed *Adapted from webopedia.com’s definition and Gaddis’ definition. Chapter 1

15 Pseudocode Example Store hours worked from user input into memory
Store hourly pay rate from user input into memory Multiply value of hours worked (in memory) by the hourly pay rate (in memory)* Store result into memory Display result (in memory) as output *Simple gross pay calculation ignoring overtime rates. Chapter 1

16 Controls (Objects) Control Prefix Example Description Form frm frmMain
GUI interface Button btn btnClose Rectangular object that triggers event procedure when clicked Label lbl lblGrossPay Box displaying text that user can’t change (descriptions & output) Text txt txtPayRate Rectangular area for data input by user Chapter 1

17 Control Prefixes (p. 9) chk Check Box cbo Combo Box btn Button
frm Form grp Group Box lbl Label lst List Box mnu Menu rad Radio Button pic Picture Box txt Text Box Chapter 1

18 Download Student Chapter 1 Files
Run Program2\bin\Program2.exe See p. 10 Chapter 1

19 Measures of Quality Must fulfill users’ needs.
Include required functionality. Perform functions correctly. Should be easy to use with little training. Design for clarity. Should be understandable looking at coding. Should have flexibility integrated for future versions of application. Chapter 1

20 System Development Life Cycle
Involves joint effort of users & programmers. Identify user requirements. Design the application. Construct the application. Implement the system. Chapter 1

21 Step 1: Identify User Requirements
Review request forms from users. Communicate with users. Identify current problems & concerns. Determine users’ needs: Features Method of operation Obtain contract if you are the outsource for another organization. Chapter 1

22 Step 1, continued Clearly define what the program should do. Purpose
To calculate the user’s gross pay. Input # of hours worked Hourly pay rate Process Multiply # of hours worked by the hourly pay rate to obtain gross pay. Output Display a message indicating the user’s gross pay. Chapter 1

23 Step 2: Design (Plan) the Application
Create blueprint of application. Sketch components for each user interface, similar to storyboarding. Chapter 1

24 Step 2, continued List needed controls (text boxes, labels, & buttons). Specify properties/attributes (Text) for each control. Specify methods/events (Click) for each control. Write pseudocode &/or flowchart Show design to users & obtain their feedback (very critical). Revise design based on feedback and continue cycle of user input. Chapter 1

25 Step 2 (List Controls Needed)
Type Name Description TextBox txtHoursWorked Allows the user to enter the number of hours worked. TextBox txtPayRate Allows the user to enter the hourly pay rate Label lblGrossPay Displays the gross pay, after the btnCalcGrossPay button has been clicked Button btnCalcGrossPay When clicked, multiplies the number of hours worked by the hourly pay rate Button btnClose When clicked, terminates the application Chapter 1

26 Step 2 (Define Control Property Values)
Property—characteristic, such as control name Value—specific attribute, such as lblGrossPay Control Type Control Name Text Form (Default) "Wage Calculator" Label (Default) "Number of Hours Worked" Label (Default) "Hourly Pay Rate" Label (Default) "Gross Pay Earned" Label lblGrossPay "$0.00" TextBox txtHoursWorked "" TextBox txtPayRate "" Button btnCalcGrossPay "Calculate Gross Pay" Button btnClose "Close" Chapter 1

27 Step 2 (List Methods for Controls)
Methods—specific actions to perform based on specific user action, such as mouse click Method Description btnCalcGrossPay_Click Multiplies the number of hours worked by the hourly pay rate These values are entered into the txtHoursWorked and txt-PayRate TextBoxes The result is stored in the lblGrossPay Text property btnClose_Click Terminates the application Chapter 1

28 Step 2 (Write Pseudocode)
Create a pseudocode version of each method: Pseudocode is a combination of English and a programming language Critical to effect planning; saves valuable time when you start actual programming; minimizes errors as you program. For this application: Store Number of Hours Worked times Hourly Pay Rate in grossPay. Store the value in grossPay in lblGrossPay.Text. Chapter 1

29 Step 2 (Continued) Check the code for errors:
Go step by step through the code, running it in your head as though the computer is running it. Keep track of where in the code is being executed. Keep track of the values of all of the variables. Chapter 1

30 Begin Program Input hourly rate Input # of hours worked
Are the # of hours > 40? No Multiply the hours worked by the hourly rate. Yes Multiply 40 by the hourly rate to get the regularly weekly pay. Subtract 40 from the total hours worked to find the OT hours. Multiply the pay rate by 1.5 to get the OT rate. Multiply the OT hours by the OT rate to get the amount of OT pay. Add the regular weekly pay and the OT pay. Display gross pay End Program Chapter 1

31 Begin Program Input hourly rate Input # of hours worked
Are the # of hours > 40? No Multiply the hours worked by the hourly rate. Yes Multiply 40 by the hourly rate to get the regularly weekly pay. Subtract 40 from the total hours worked to find the OT hours. Multiply the pay rate by 1.5 to get the OT rate. Multiply the OT hours by the OT rate to get the amount of OT pay. Add the regular weekly pay and the OT pay. Display gross pay End Program Chapter 1

32 Step 3: Construct the Application
Use VB to create the application. Create one piece (form) at a time. Create form (user interface window) and set its properties. Insert controls based on design specs. Set properties for all controls. Write code for the event procedures. Use pseudocode to create event procedures into correct syntax. Chapter 1

33 Step 3 (continued) Run the program.
Test and debug the application throughout development. Correct syntax errors, incorrect use of the language, such as keyword. Correct logic errors, errors that don’t crash the program but produce inaccurate results, such as adding instead of multiplying. Use various examples of test data (different numbers, names, etc.). Chapter 1

34 Getting Started Create folder on H drive: ISYS1200
Create subfolders w/ in ISYS1200 Practice Assignments Slide Shows Chapter 1

35 Visual Basic .NET Interface
Start program (see p. 22). Specify folder and subfolder location (Location text box). Type program name (Name text box). Chapter1GrossPay MulberyAssignment1 (for assignments) Folder created within location based on project name typed Chapter 1

36 Project Numerous files to run program
Keep in same folder; do not copy/paste program files. Can copy/paste image files (bmp) into project folder if need images Chapter 1

37 Visual Basic .NET Environment
Project name Mouse over to see Toolbox Design window (displays form) Form(s) within Solution Explorer Form (interface) Property window for selected object (currently the form) Chapter 1

38 Design Window Application’s forms Area where you design the interface
Grid visible for programmer (not user) Chapter 1

39 Solution Explorer Window
Solution (container for storing project files) Chapter 1

40 Properties Window Displays settings for currently selected object
Changes based on what is selected Currently shows properties for form object Second example when a Label control object is selected Note: Some properties set at Design Time in Properties window. Other properties set with programming code. Chapter 1

41 Form Properties Text StartPosition MaximizeBox and MinimizeBox Icon
Appears on title bar StartPosition Form location onscreen WindowsDefault (default setting) CenterScreen (typical) MaximizeBox and MinimizeBox True (Default) False (Dims or hides) Icon Symbol in top left corner (left of Text property) Chapter 1

42 ToolBox Unpinned Pinned (stays onscreen) Chapter 1

43 Textbook Reference USE IT—YOU PAID FOR IT!!!!
Read information (pp ). Complete tutorials (pp ). Answer Check Points (p. 34). Check answers in back of book (p. 819) Note key terms (pp ) Answer Review Questions (pp ). Sometimes these make good test questions! Check answers from ftp site Chapter 1

44 Reminder Send e-mail to mulberke@uvsc.edu by 5 p.m. today (January 8).
Chapter 1


Download ppt "Intro to Programming and Visual Basic .NET"

Similar presentations


Ads by Google