Tutorial 101 Variable Arrays A group of variables that have the same name and data type and are related in some way Can have as many as 60 dimensions.

Slides:



Advertisements
Similar presentations
1.
Advertisements

Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Eight Sub and Function Procedures.
Microsoft Visual Basic 2010: Reloaded Fourth Edition
1.
Programming with Microsoft Visual Basic 2005, Third Edition
The ADO Data Control. Universal Data Access Open Database Connectivity (ODBC) –standard for accessing data in databases OLE-DB –allows access to data.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
An Introduction to Programming with C++ Fifth Edition
Arrays-Part 1. Objectives Declare and initialize a one-dimensional array Store data in a one-dimensional array Display the contents of a one-dimensional.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 8 Arrays.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Arrays.
Chapter 7: Sub and Function Procedures
Chapter Three Using Variables and Constants Programming with Microsoft Visual Basic th Edition.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
Chapter 8: String Manipulation
Automation Testing- QTP Rajesh Charles Batch No: Date: jan
Chapter 3: Using Variables and Constants
Programming with Microsoft Visual Basic th Edition CHAPTER THREE USING VARIABLES AND CONSTANTS.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Copyright © 2001 by Wiley. All rights reserved. Chapter 10: Advanced Database Operations Revising Vintage Videos Setting RecordSource at run time DBGrid.
IE 212: Computational Methods for Industrial Engineering
Object Variables Visual Basic for Applications 3.
1 Microsoft Visual Basic 2010 Arrays. 2 Using a One-Dimensional Array Lesson A Objectives After completing this lesson, you will be able to:  Declare.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Using Arrays and File Handling
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Twelve Access Databases and LINQ.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Working with Numeric Variables (Unit 6) Visual Basic for Applications.
Numeric Variables Visual Basic for Applications 6.
Mouse Events. Mouse Driven Events Unlike control_click() which is passed no arguments (unless it's an index for an array), MouseDown, MouseUp and MouseMove.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Chapter 10: Structures and Sequential Access Files
Chapter Ten Structures and Sequential Access Files Programming with Microsoft Visual Basic th Edition.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Date Variables Visual Basic for Applications 5. Objectives n In this tutorial, you will learn how to: n Reserve a Date variable n Use an assignment statement.
1 Week 6 The Repetition Structure. 2 The Repetition Structure (Looping) Lesson A Objectives After completing this lesson, you will be able to:  Code.
Arrays Chapter 8. Chapter 8 - Part 12 Variable and Variable Array Variable Stores only one value Variable Array Variable that has 1 symbolic name but.
Tutorial 6 The Repetition Structure
Tutorial 91 Databases A database is an organized collection of related information stored in a file on a disk A database allows companies to store information.
Computer Programming TCP1224 Chapter 11 Arrays. Objectives Using Arrays Declare and initialize a one-dimensional array Manipulate a one-dimensional array.
1 Working with Data Structures Kashef Mughal. 2 Chapter 5  Please review on your own  A few terms .NET Framework - programming model  CLR (Common.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 18 – Student Grades Application Introducing.
Lab 6 (2) Arrays ► Lab 5 (1) Exercise Review ► Array Concept ► Why Arrays? ► Array Declaration ► An Example of Array ► Exercise.
Introduction to Excel VBA UNC Charlotte CPE/PDH Series December 17, 2009.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley More About Array Processing 8.2 There Are Many Uses of Arrays and Many Programming.
INSERT BOOK COVER 1Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Getting Started with VBA for Microsoft Office 2010 by.
Programming with Microsoft Visual Basic th Edition
Tutorial 3: Using Variables and Constants1 Tutorial 3 Using Variables and Constants.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Ten Structures and Sequential Access Files.
Programming with Microsoft Visual Basic 2012 Chapter 9: Arrays.
Creating Menus Menu Bar – behaves like standard Windows menus Can be used in place of or in addition to buttons to execute a procedure Menu items are controls.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Understanding Visual Basic Fundamentals CHAPTER 13 Understanding Visual Basic Fundamentals.
Controlling Program Flow with Decision Structures.
Tutorial 81 Field, Record, Data File Field - a single item of information about a person, place, or thing Record - a group of related fields that contain.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Lab 5 Arrays ► Lab 4 Exercise Review ► Array Concept ► Why Arrays? ► Array Declaration ► An Example of Array ► Exercise.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
The Advantage Series ©2005 The McGraw-Hill Companies, Inc. All rights reserved Chapter 12 Introducing Visual Basic for Applications Microsoft Office Excel.
Excel Tutorial 8 Developing an Excel Application
VBA - Excel VBA is Visual Basic for Applications
VISUAL BASIC.
Tutorial 11 Arrays Tutorial 11: Arrays.
Presentation transcript:

Tutorial 101 Variable Arrays A group of variables that have the same name and data type and are related in some way Can have as many as 60 dimensions in Visual Basic; the most commonly used arrays are one- dimensional and two-dimensional Programmers use arrays to store related data in the internal memory of the computer Data stored inside the computer can be both written and read much faster than data stored in a file on a disk

Tutorial 102 Variable Arrays A one-dimensional array is simply a row (or column) of variables; a two-dimensional array resembles a table in that it has rows and columns Each element in an array is identified by a subscript You refer to an array element by the array’s name followed by the element’s subscript

Tutorial 103 One-dimensional Array NebraskaNew JerseyNew Mexico Tennessee Texas Nebraska New Jersey New Mexico Tennessee Texas

Tutorial 104 Two-dimensional Array Nebraska New Jersey New Mexico Tennessee Texas Lincoln Trenton Santa Fe Nashville Austin

Tutorial 105 One-dimensional Array Dim arrayname(lower subscript To upper subscript) As datatype Public arrayname(lower subscript To upper subscript) As datatype Lower subscript and upper subscript are numbers that define the lowest and the highest subscript in the array The Dim (and Public) statements create and initialize the array variables in memory

Tutorial 106 One-dimensional Array Dim strMonthArray(1 To 6) As String Dim intSquareArray(1 To 5) As Integer Dim sngNum(1 To 10) As Single Dim udtEmp(1 To 20) As EmpStruc Note: It is not necessary for an array name to contain the word “Array”

Tutorial 107 One-dimensional Array strMonthArray(1) = “Jan” strMonthArray(2) = “Feb” strMonthArray(3) = “Mar” strMonthArray(4) = “Apr” strMonthArray(5) = “May” strMonthArray(6) = “June”

Tutorial 108 One-dimensional Array For intNum = 1 to 5 intSquareArray(intNum) = intNum * intNum Next intNum For intNum = 1 to 10 sngNum(intNum) = Val(InputBox(“Enter number”)) Next intNum

Tutorial 109 One-dimensional Array Do While Not EOF(1) intNum = intNum + 1 Input #1, udtEmp(intNum).Name, udtEmp(intNum).Salary Loop

Tutorial 1010 Calculating the Average Declare variables Repeat for intNum = 1 to 20 by 1 add array score to intTotal variable End repeat for intNum Calculate the average by dividing intTotal by 20 Display the average

Tutorial 1011 Finding the Highest Value Declare variables Assign first array value to intHigh variable Repeat for intNum = 2 to 20 by 1 If current array value > intHigh value then assign current array value to intHigh End If End repeat for intNum Display the highest value(stored in intHigh)

Tutorial 1012 Updating an Array Declare variables Prompt user for the value to add Repeat for intNum = 2 to 20 by 1 add value to current array value End repeat for intNum Display “Updated” message Open a file Repeat for intNum = 1 to 20 by 1 Write array value to file End repeat for intNum Close the file

Tutorial 1013 Two-dimensional Array Dim arrayname(lower subscript To upper subscript, lower subscript To upper subscript) As datatype Public arrayname(lower subscript To upper subscript, lower subscript To upper subscript) As datatype

Tutorial 1014 Two-dimensional Array Dim strNameArray(1 To 6, 1 To 3) As String Dim intNum(1 To 5, 1 To 10) As Integer Dim sngSales(1 To 20, 1 To 2) As Single Note: It is not necessary for an array name to contain the word “Array”

Tutorial 1015 Two-dimensional Array Declare variables Open the file Repeat for intRow = 1 to 4 by 1 Repeat for intCol = 1 To 2 by 1 Read name from file and store it in the current array element End repeat for intCol End repeat for intRow Close the file

Tutorial 1016 DataGrid Control When bound to an ADO data control, the DataGrid control displays the information from the recordset created by the ADO data control’s RecordSource property The information displays in a row and column format, with each database field appearing in a column, and each record appearing in a row The intersection of a column and a row is called a cell

Tutorial 1017 DataGrid Control Use the Components option on the Project menu to add the Microsoft DataGrid Control 6.0 (OLEDB) tool to the toolbox, then place a DataGrid control in the interface dgd is the three-character ID for a DataGrid control You bind a DataGrid control to the ADO data control by setting the DataGrid control’s DataSource property

Tutorial 1018 DataGrid’s Popup Menu

Tutorial 1019 Sizing Columns

Tutorial 1020 General Tab

Tutorial 1021 General Tab Check Boxes (Properties) AllowAddNew - allows the user to add records while the application is running AllowDelete - allows the user to delete records while the application is running AllowUpdate - allows the user to edit existing records while the application is running ColumnHeaders - controls whether a header appears above each column Enabled - controls whether the control responds to a user-generated event

Tutorial 1022 Columns Tab

Tutorial 1023 Format Tab

Tutorial 1024 Layout Tab

Tutorial 1025 Five DataGrid Events BeforeColUpdate AfterColUpdate AfterColEdit BeforeUpdate AfterUpdate

Tutorial 1026 Referring to a Field Within the Fields Collection Syntax for referring to a field within a Recordset object’s Fields collection: [form.]adocontrol.Recordset.Fields(field) field is the name of the field enclosed in quotation marks

Tutorial 1027 Creating an Object Variable Dim objectVariableName As datatype Dim objFlds As Object Dim objRst As Recordset datatype can be a specific object type (such as Sheet, Range, or Recordset) or the keyword Object, which can be used to represent a reference to any object

Tutorial 1028 Assigning an Object Reference to an Object Variable Set objectVariableName = object Set objFlds = adoPay.Recordset.Fields Set objRst = adoPay.Recordset After assigning the reference to the object variable, you can use the shorter object variable’s name in the code

Tutorial 1029 Round Function Round(expression [,numdecimalplaces]) Returns a number rounded to a specific number of decimal places expression is a numeric expression numdecimalplaces is a number indicating how many places to the right of the decimal are included in the rounding

Tutorial 1030 Function Procedure Referred to simply as a function Like a sub procedure, a function is a block of code that performs a specific task Unlike a sub procedure, a function returns a value Some functions are intrinsic (Val, Round) You also can create your own functions, referred to as user-defined functions

Tutorial 1031 Function Syntax Private Function functionname [(arglist)] As datatype [statements] functionname = expression End Function The functionname = expression statement assigns the return value to the function To invoke a function you need simply to include the function’s name in a statement

Tutorial 1032 Debugging Technique You can use the Debug menu’s Toggle Breakpoint and Add Watch commands to help you debug an application

Tutorial 1033 Breakpoint Instruction

Tutorial 1034 Add Watch Dialog Box

Tutorial 1035 Watches Window

Tutorial 1036 Watches Window Showing Current Values of Watch Expressions