Microsoft Visual Basic 2005 BASICS

Slides:



Advertisements
Similar presentations
C ONTINUE... V ARIABLE -N AMING C ONVENTIONS When declaring variables, you should be aware of few naming conventions. A variable’s name: Must begin with.
Advertisements

Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
VBA for MS Excel Hamze Msheik. Open the Visual Basic Editor in Excel 2007 Click on the Microsoft Office button in the top left of the Excel window and.
Introduction to C Programming
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
VB Code Statements 3 types of VB statement The Remark statement, known as comments, are used for project documentation only Begin with an apostrophe Not.
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.
110-D1 Variables, Constants and Calculations(1) Chapter 3: we are familiar with VB IDE (building a form…) to make our applications more powerful, we need.
Variables, Constants, Methods, and Calculations Chapter 3 - Review.
Microsoft® Small Basic
Variables and Constants
Chapter 3: Using Variables and Constants
CS0004: Introduction to Programming Variables – Numbers.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.
Tutorial 11 Using and Writing Visual Basic for Applications Code
Using Visual Basic 6.0 to Create Web-Based Database Applications
CHAPTER THREE Representing Data: Constants and Variables.
National Diploma Unit 4 Introduction to Software Development Data types, variables and constants.
Microsoft Visual Basic 2005 BASICS Lesson 4 Mathematical Operators.
Lab 01 Forms in excel Tahani ALdweesh Insert form into your project. 2. Change form’s properties. 3. Put controls on the form. 4. Change controls’
Visual Basic.NET BASICS Lesson 4 Mathematical Operators.
Representing Data: Constants and Variables CHAPTER THREE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009.
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 BASICS Lesson 3 Events and Code.
Fundamentals of GUI Programming. Objectives: At the end of the session, you should be able to: describe the guidelines that are used for creating user-friendly.
Introduction to VB.NET 2005 Dr. McDaniel IDS4704 Spring 2005.
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.
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.
Programming with Microsoft Visual Basic th Edition
Tutorial 3: Using Variables and Constants1 Tutorial 3 Using Variables and Constants.
Lesson 4 Mathematical Operators! October 6, 2009.
Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
Variables in VB.NET. Variables  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can.
Visual Basic CDA College Limassol Campus COM123 Visual Basic Programming Semester C Lecture:Pelekanou Olga Week 3: Using Variables.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
Tutorial 3: Using Variables and Constants1 Tutorial 3 Using Variables and Constants.
Calculator Program Explained by Arafa Hamed. First Designing The Interface Ask yourself how many places are there that will be used to input numbers?
CHAPTER THREE Representing Data: Constants and Variables.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
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.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Representing Data: Constants and Variables
Unit 2 Technology Systems
Egyptian Language School Computer Department
A variable is a name for a value stored in memory.
Chapter 3: Using Variables and Constants
Working with Forms in Visual Basic
Microsoft Access Illustrated
Microsoft Visual Basic 2005 BASICS
Microsoft Visual Basic 2005 BASICS
Variables and Arithmetic Operations
2.1 Parts of a C++ Program.
Unit-1 Introduction to Java
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
Microsoft Visual Basic 2005 BASICS
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 1/15/2019.
CHAPTER FOUR VARIABLES AND CONSTANTS
Chapter 2: Introduction to C++.
Microsoft Visual Basic 2005 BASICS
Variables in C Topics Naming Variables Declaring Variables
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 7/9/2019.
Variables and Constants
Presentation transcript:

Microsoft Visual Basic 2005 BASICS yo Microsoft Visual Basic 2005 BASICS Lesson 5 Data Types and Variables

Objectives Describe the purpose of data types and variables. yo Objectives Describe the purpose of data types and variables. Use the AutoSize property. Declare and use variables. Describe the scope of variables. Describe the Object data type. Microsoft Visual Basic 2005 BASICS

Data Types Computers are all about data. yo Data Types Computers are all about data. Visual Basic supports a certain set of data types. You can choose to store data in memory locations called variables. Variables Can be used to store and manipulate all kinds of data Microsoft Visual Basic 2005 BASICS

Data Types (cont.) Microsoft Visual Basic 2005 BASICS

Using the AutoSize Property yo Using the AutoSize Property The AutoSize property Adjusts the size of a control to fit its contents Label control example The AutoSize property will shrink or enlarge the label to fit the text. Microsoft Visual Basic 2005 BASICS

Using the AutoSize Property (cont.) Microsoft Visual Basic 2005 BASICS

Using the AutoSize Property (cont.) Microsoft Visual Basic 2005 BASICS

Declaring Variables Using a variable in your programs Let the compiler know That you want to set up a memory location as a variable What you want to call the variable What data type you want the variable to have Declare a variable Use the Dim statement Microsoft Visual Basic 2005 BASICS

Rules for Naming Variables yo Rules for Naming Variables When naming variables, keep the following rules in mind: Variable names must begin with an alphabetic character. Following the first character, letters, numbers, and underscores are allowed. Variable names cannot include spaces. Variable names can be 255 characters long. Microsoft Visual Basic 2005 BASICS

Rules for Naming Variables (cont.) Microsoft Visual Basic 2005 BASICS

yo Using Variables Variables can be used in the same way as labels and text boxes. Use the assignment operator to assign a value to a variable. You can also assign hard-coded values to a variable. Microsoft Visual Basic 2005 BASICS

Using Variables (cont.) Use mathematical operators to perform calculations with numeric variables. Output the value in a variable. Assign the value to a label. Microsoft Visual Basic 2005 BASICS

Using Variables (cont.) Microsoft Visual Basic 2005 BASICS

Using Variables (cont.) Microsoft Visual Basic 2005 BASICS

Scope The term “scope” refers to the reach of a variable. General rule yo Scope The term “scope” refers to the reach of a variable. General rule You should declare variables as locally as possible. Microsoft Visual Basic 2005 BASICS

Three Levels of Scope Levels Local variable Form-level variable yo Three Levels of Scope Levels Local variable Declared within an event procedure Form-level variable Declared in the Declarations section of a form’s Code window Global variable Declared in a code module’s section Microsoft Visual Basic 2005 BASICS

The Declarations Section yo The Declarations Section Access the Declarations section Select (Declarations) from the Method Name list that appears at the top of the Code window. Microsoft Visual Basic 2005 BASICS

The Declarations Section (cont.) Microsoft Visual Basic 2005 BASICS

The Declarations Section (cont.) Microsoft Visual Basic 2005 BASICS

Using the Object Data Type yo Using the Object Data Type Object data type Very flexible Can store many different types of variables Object variables Can be declared by specifying the Object type Or by declaring a variable without a type Microsoft Visual Basic 2005 BASICS

yo Summary Data can be in the form of numbers, text, dates, pictures, and even sound. Visual Basic supports a set of data types. There are data types for whole numbers, floating-point numbers (decimals), text, dates, and more. You can choose to store data in memory locations called variables. Microsoft Visual Basic 2005 BASICS

Summary (cont.) The AutoSize property will adjust the size of a control to fit its contents. The first step to using a variable is to declare it using the Dim statement. When naming variables, keep the naming rules in mind. It is a good idea to use naming prefixes to identify the data type of the variable. Microsoft Visual Basic 2005 BASICS

yo Summary (cont.) You can assign values to variables using the assignment operator. You can also use the other mathematical operators with numeric variables. A variable’s scope indicates the procedures that have access to the variable. A variable’s scope can be local, form-level, or global. Microsoft Visual Basic 2005 BASICS

yo Summary (cont.) The Declarations section of a form’s Code window allows you to declare form-level variables. The Object data type can hold many different kinds of data, but is less efficient than specific data types. Microsoft Visual Basic 2005 BASICS