Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.

Slides:



Advertisements
Similar presentations
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Advertisements

Lecture Set 4 Data Types and Variables Part B – Variables, Constants, Expressions Conversion Rules Options Strict, Option Explicit Scope of Definition.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Chapter Three Using Variables and Constants Programming with Microsoft Visual Basic th Edition.
Copyright © 2001 by Wiley. All rights reserved. Chapter 3: Variables, Assignment Statements, and Arithmetic Variables Assignment Statements Arithmetic.
Slide 1 Chapter 2 Visual Basic Interface. Slide 2 Chapter 2 Windows GUI  A GUI is a graphical user interface.  The interface is what appears on the.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Visual Basic Chapter 1 Mr. Wangler.
Variables and Constants
Chapter 3: Using Variables and Constants
05/09/ Introducing Visual Basic Sequence Programming.
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
Chapter 12: How Long Can This Go On?
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
Basic Controls & Properties Chapter 2. Overview u VB-IDE u Basic Controls  Command Button  Label  Text Box  Picture Box u Program Editor  Setting.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
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”
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
Game Maker – Getting Started What is Game Maker?.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Three Memory Locations and Calculations.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
Programming with Microsoft Visual Basic th Edition
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
110 E-1 Variables, Constants and Calculations(2) Chapter 3: Operations on variables, scope of a variable, formatting data Doing Arithmetic.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
Controlling Program Flow with Decision Structures.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Programming with Visual Basic.NET. Quick Links Program Code The Code Window The Event Procedure Assignment Statements Using AutoList Radio Buttons Buttons.
Making Interactive Programs with Visual Basic .NET
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
Representing Data: Constants and Variables
Microsoft Visual Basic 2010 CHAPTER FOUR Variables and Arithmetic Operations.
Bill Tucker Austin Community College COSC 1315
Visual Basic.NET Windows Programming
Egyptian Language School Computer Department
A variable is a name for a value stored in memory.
Topics Designing a Program Input, Processing, and Output
Arithmetic operations and operators, converting data types and formatting programs for output. Year 11 Information Technology.
An Application Uses Variables to Hold Information So It May Be Manipulated, Used to Manipulate Other Information, or Remembered for Later Use.
Variables and Arithmetic Operations
Chapter 3: Using Variables and Constants
How to design a Windows Forms application
CHAPTER FIVE Decision Structures.
2. Understanding VB Variables
Microsoft Access Illustrated
Lecture Set 4 Data Types and Variables
Chapter 2 Visual Basic Interface
CHAPTER FIVE Decision Structures.
Variables and Arithmetic Operations
Microsoft Visual Basic 2005 BASICS
Variables ICS2O.
CIS16 Application Development Programming with Visual Basic
VB.NET PROGRAMMING FINAL EXAM TEST REVIEW.
CS285 Introduction - Visual Basic
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Chapter 2: Introduction to C++.
Introduction to Programming
Presentation transcript:

Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________ is used as a container for other controls. This is an example of a _________________________________________ … a control that serves as a holding area for other controls, indicating that the controls are somehow related. More often than not you’ll find radio buttons inside of the GroupBox Control. RADIO BUTTON CONTROLS The ______________________________________________ presents a set of choices … such as the number of years in the car loan. Radio Buttons are placed in _______________________ so that only ONE may be selected at a time. In order to do this it is important that you draw the radio buttons directly into the GroupBox Control. If you do it right, you won’t have to write any additional code to enforce this rule – it will just work! If you want more than one group of radio buttons just add more than one GroupBox control! The prefix for naming radio button controls is “__________”. Example: ________________ GROUPBOX CONTROL PROPERTIES A GroupBox Control can only have a rectangular shape. A GroupBox Control can have a label, indicated by its Text Property Value. When RadioButtons are added inside a GroupBox, only one can be selected at a time. In general, you don’t have to rename your GroupBoxes since you don’t usually write code for them. FYI though: the naming prefix is “__________________” RADIO BUTTON PROPERTIES As you’ve learned, only one radio button within a group can be on at once. The _______________________________________ keeps track of which one is selected. The checked property is either _____________________________. When one button in a group becomes true, all the others automatically become false. ______________________________ determines the 3D appearance of the control ______________________________ – defines the visible text that displays on the control. USING THE LAYOUT TOOLBAR The _______________________________ contains tools that allow you to adjust the alignment, spacing, and size of any group of controls on the form. This really simplifies the task of changing the size & position of controls on your form! To select more than one control: Press and hold down the _____________________ and then click on the other controls! Most popular features on the layout toolbar: Make same size Align Lefts, Rights, Tops and Bottoms Center Horizontally and Center Vertically Increase or Decrease Spacing Between Controls

Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions COOL SHORTCUT TO PUT IN FOR THE END-USER It is helpful to the end user if they can just hit the enter key and have the program execute it’s intended purpose. That is done by setting the _________________________. Just select the ______________________________ property in the Form’s Property List. Just choose the button that should be the default! LOCKING CONTROLS ON A FORM ________________________________ – This disallows the ability to move controls or modify control sizes on a form during design time – protects you from yourself! Click on your form, then go up to Format on the menu bar, and select Lock Controls CONSTANTS AND VARIABLES A _________________________is a number or string that programmers use in the code. For example 150, 0.83, 8.14, “yes” or “no” A ______________________ represents a location in computer memory that can change values as the code executes A _______________________ represents a location in computer memory that cannot be changed during execution VARIABLES _________________________________ are used in code statements to temporarily store values so that they may be used again in other calculations. Variables are created by ____________________. They must have a ___________ and a ________. The name and type are decided on by the programmer. To decide upon the type you must _____________________________________________________________________________. DATA TYPES The __________________________ of a variable or constant determines what kind of data it can store. Here are some VB variable types (list at least 3) _____________, ____________, ____________! VARIABLE NAMES There are rules to naming your variables: The name _____________________________________________________________ ! The name ______________________________________________________________!  The name _____________________________________________________. The easiest way to create a variable is to __________________________________________ ___________________________________. For ex: __________________ or ________________. NAMING CONVENTIONS FOR VARIABLES You don’t have to remember all of these at once … you’ll get the hang of them as you start creating and naming variables! Just start the variable name off with the proper prefix. Then give it a name that describes what it is storing! Short ________ Integer ________ Long ________ Byte ________ Decimal ________ Single ________ Double ________ Char ________ String ________ Boolean ________ Date ________ Object ________

Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions MORE ON VARIABLES Variables created in this way may hold either numbers (________________) or characters (_______________________). Character data is called a ________________ and must be placed in _______________________________________. Ex: name=“Christy” Examples of code statements that assign variables: Numeric Data -- ___________________________________ String Data -- ___________________________________ Value of another variable -- ___________________________________ value of an expression -- ___________________________________ Note : the ____________________________________________ must be on the left side. UNDERSTANDING THE OPTION STRICT STATEMENT When you use assignment statements .NET does not require you to use the same data type on both sides of the equal sign. .NET will attempt to make it work but this can lead to a bunch of errors at run time. For example… lets say you declare a variable as a short and then try to store a value of 50,000 in it. Shorts only go up to about 32,000. This will cause the program to come to a screeching halt. The ________________________________ can be used to instructs Visual Basic .NET to force you to ensure that all assignment statements use the same data type on both sides of the equal sign. USING OPTION STRICT This makes it a bit more tedious to code BUT the benefit is that .NET will let you know when you are doing it wrong and prompt you to fix it! Being in Option Strict mode also means that ___________________________________________! That’s good for beginning programmers. It keeps you honest!  How do you get into Option Strict mode? In the code window on line 1, type _______________________ DECLARING A VARIABLE Generally speaking, variables need to be _______________________. The computer needs you to tell it the _______________________________ and ______________________________________. There are many different types of variables. Some types are _______________, _________________, _________________, ____________. To declare a variable you use the keyword _______________. Example: __________________________________________ _________________________refers to a variables ability to be accessed throughout a program. It is defined by where the variable is declared. The scope can be limited to one procedure … for example: the variable will work within a given calculate button procedure OR it can be available throughout an entire form. Let’s give some examples: DECLARING GLOBAL VARIABLES ________________________________________ are those that are available to all the procedures on a given form. To declare a global variable type the Dim line in the Public Class Section of the Code Window. (Right below the REM Lines where you put your name!) Also, put a “________________” in front of the name to indicate that it’s a global variable! For Example: _______________________________________________ DECLARING LOCAL VARIABLES _____________________________________ are those that only work in a single procedure. To declare a local variable go to the specific event procedure where you want the variable to work and write the DIM statements there! For example: in the btnCalculate_Click Event: (Give one example of a local variable declaration) ______________________________________________________

Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions DECLARING CONSTANTS Give one example of a Constant Declaration Statement using the Keyword Const: ___________________________________________________ CONVERTING DATA TYPES Because Option Strict is on in this chapter, you have to insure that all the data being used by the calculations has the same data type … if you don’t, you’ll get an error! For example: In the main project the nudLoanAmount box has a Decimal Value Type. Your calculation needs to go into a Double Variable. Therefore you need to convert it. Luckily, .NET has simple-to-use conversion statements. For example: _______________________________________________________________ CODING A FORM LOAD EVENT PROCEDURE Every event has a default event … for command buttons it is the Click Event. For Forms it is the _____________________________________________. This event executes when the form first loads into memory. Therefore, any code you have in the Form_Load Event will trigger whenever the form loads! NUMERIC EXPRESSIONS An ______________________ can perform a calculation, manipulate characters, call a function, or test data. A ___________________________________ is any expression that can be evaluated as a number. A numeric expression can include values, variables, constants, as well as certain control properties. Expressions often contain math problems … therefore _____________________________ and ___________________________________________________________ come into play! ARITHMETIC EXPRESSIONS VB follows the normal order of operations – which is ____________________________________________ __________________________________________. (________________________________) Arithmetic operators in Visual Basic _______ -- used to raise the power of an exponent _______ -- used to multiply two numbers _______ -- used to divide 2 #’s and return a decimal result _______ -- used to divide 2 #’s and return an integer result _______ -- Used to divide 2 #’s and return only the remainder _______ -- used to sum 2 #’s _______ -- Used to subtract 2 #’s or indicate a negative value INTRINSIC FUNCTIONS VB programmers created a set of _______________________________ – functions that are built into .NET. You used one of those Intrinsic Functions in your main project. It was the _______________________. This is a financial function that will return the payment for a loan based on periodic, constant payments and a constant interest rate. Pmt (rate, number of periods, pv, fv, due) This is what it looked like in your code: ______________________________________________. There is a list of additional intrinsic functions on page 4.59 in your book! USING THE FORMAT$ FUNCTION The Format$ Function is an Intrinsic function that allows you to apply a “better look” to your output. For instance, what if you want to round an answer to a certain number of decimal places OR you want the answer to display as a $$$ value. Use the format$ function! ___________________________________ -- function that allows the programmer to determine how the output will appear on the screen. Ex: ________________________________________________________________________ Some popular formats are ________________________, _________________________, ____________________________, ________________________ and _________________.

Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions Use the note space below for the following Coding 101 topics: Valid and invalid variable names Arithmetic operators Order of operation _________________________________________________________________