Pay Example (PFirst98) Please use speaker notes for additional information!

Slides:



Advertisements
Similar presentations
5.04 Apply Decision Making Structures
Advertisements

Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Val Function A Function performs an action and returns a value The expression to operate upon, known as the argument, (or multiple arguments), must be.
Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data.
Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data.
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command button As a result the Visual Basic Code Window.
Muffin Shop - if, calculations etc. (muffins, muffins2) Please use speaker notes for additional information!
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
© 1999, by Que Education and Training, Chapter 5, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
InvEasy (Project1) Please use speaker notes for additional information!
CS0004: Introduction to Programming Variables – Strings.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Chapter 4: The Selection Process in Visual Basic.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
Chapter 9 - VB.Net by Schneider1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes, Combo Boxes, and the File-Opening Control The List Box Control.
Types and Loops.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Programming Test #1 Solutions. Multiple Choice 1. B) the grammar of the coding language 2. C) String 3. A) Single 4. C) 2Burgers4Me 5. B) Design Time.
Do Loop with Interest Please see speaker notes for additional information!
New Project in Visual Basic Please use speaker notes for additional information!
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
1 Flow Control II Code: Select-Case and For-Next Controls: Frames and OptionButtons.
CS0004: Introduction to Programming Project 1 – Lessons Learned.
University of Sunderland CIF 104 Fundamentals of DatabasesUnit 16 SESSION 16 VBA example.
Class 3 Remote Instruction Computer Math EDU 556 Programming for Instruction Dr. Steve Broskoske This is an audio PowerCast. Make sure your volume is.
Applications Development
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
COMPUTER PROGRAMMING I SUMMER Apply operators and Boolean expressions.
Delivery and other DO Examples Please use speaker notes for additional information!
Chapter 3 w Variables, constants, and calculations DIM statements - declaration temporary memory locations identifier, data type, scope data types - values.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Chapter 3 Control Structures. The If…Then Statement The If…Then statement is a Decision statement = that executes a set of statements when a condition.
VAT Calculator program Controls Properties Code Results.
Hungarian Notation A must in this course Every object used MUST be renamed including the form(s) using the following rules Form  frmFormName E.g. frmTemperature.
Visual Basic I/O Programs (ProjRead1, ProjRead2, ProjWrite1, ProjPay) Please use speaker notes for additional information!
Programming with Microsoft Visual Basic th Edition
COMPUTER PROGRAMMING I SUMMER Apply operators and Boolean expressions.
Maximum Profit Please use speaker notes for additional information!
CECS 5020 Computers in Education Visual Basic Variables and Constants.
31/01/ Selection If selection construct.
Variables Continued In the last session we saw how variables are objects that allow us to store values in the RAM of the computer In this session we shall.
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
Controlling Program Flow with Decision Structures.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
Using a Database Access97 Please use speaker notes for additional information!
Adding Code to the Option Button. Open VB 1.Double click the Calculate button and select General from the Object list box. 2.Add the following code to.
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
I am using Visual Basic 6 for this class. If you want to use a different version, please contact me. Thanks!
More Visual Basic Code: if-then-else, for loops Controls: Multiple forms, List Boxes, Radio buttons, frames,
Subroutines (PrArith, Math,projCP1, PrAdrProc, PrAdrProcFunc) Please use speaker notes for additional information!
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Visual Basic Declaring Variables Dim x as Integer = 0 In the statement above, x is being declared as an Integer (whole number) and is initialised.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
Multiple forms - SDI & MDI Please use speaker notes for additional information!
TUTORIAL 4 Visual Basic 6.0 Mr. Crone. Pseudocode Pseudocode is written language that is part-code part- English and helps a programmer to plan the layout.
A variable is a name for a value stored in memory.
3rd prep. – 2nd Term MOE Book Questions.
3rd prep. – 2nd Term MOE Book Questions.
Please use speaker notes for additional information!
Tutorial 12 – Security Panel Application Introducing the Select Case Multiple-Selection Statement Outline Test-Driving the Security Panel Application.
Department Array in Visual Basic
Please use speaker notes for additional information!
المحاضرة السادسة.
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
Additional Topics in VB.NET
If statements (Inven1, Inven2, Inven2a, Inven3, Inven3a)
Introduction to Programming
More on If statements (Calculate, Calculate1, Calculate2)
Presentation transcript:

Pay Example (PFirst98) Please use speaker notes for additional information!

PFirst98 Note that in this example, I first built a frame to hold the option buttons. This grouped the option buttons so that only one could be pressed. Option Buttons are used when the user must select just one of the options.

Frame I drew the frame on the form in the position where I wanted it. I then named it frmType. You can also see the Caption of Type Employee.

The Value for the Option Button is True to indicate the button is selected and False to indicate the button is not selected. False is the default. Option button

Option Button

Output This shows the output. Two are Full Time and one is Part Time. Amount Earned is calculated when the Calculate button is clicked.

Calculate Button

Option Explicit Dim wkAmtEarn As Integer Private Sub CmdCalc_Click() wkAmtEarn = 0 If OptPart = True Then wkAmtEarn = Val(TxtPayHr) * Val(TxtHrs) Else If Val(TxtHrs) > 40 Then wkAmtEarn = 40 * Val(TxtPayHr) + (Val(TxtHrs) - 40) * (1.5 * Val(TxtPayHr)) Else wkAmtEarn = Val(TxtPayHr) * Val(TxtHrs) End If TxtAmtEarn = Str(wkAmtEarn) 'Str converts numeric to text - not needed 'Integer will get only whole # answer - need single to get decimals End Sub Code for CmdCalc_Click() Part 1 Code for CmdCalc_Click() Part 1 wkAmtEarn is defined as an integer with the Dim statement. Because it is at the top in the General Declarations area, it is available to events that are coded beneath. In this example there is only one. wkAmtEarn is given an initial value of 0.

Option Explicit Dim wkAmtEarn As Integer Private Sub CmdCalc_Click() wkAmtEarn = 0 If OptPart = True Then wkAmtEarn = Val(TxtPayHr) * Val(TxtHrs) Else If Val(TxtHrs) > 40 Then wkAmtEarn = 40 * Val(TxtPayHr) + (Val(TxtHrs) - 40) * (1.5 * Val(TxtPayHr)) Else wkAmtEarn = Val(TxtPayHr) * Val(TxtHrs) End If TxtAmtEarn = Str(wkAmtEarn) 'Str converts numeric to text - not needed 'Integer will get only whole # answer - need single to get decimals End Sub Code for CmdCalc_Click() Part 2 Code for CmdCalc_Click() Part 2 If OptPart is True then the wkAmtEarn is calculated by multiplying the Val of the entry in TxtPayHr by the Val of the entry in TxtHrs. Else, we check to see if the Val in TxtHrs is greater than 40. If it is, the calculation includes overtime. If it is not, the calculation is the multiplication. Note the comments. Since there were two IF statements, both must be ended. The answer is converted to a string and put in the TxtAmtEarn text box on the form.