Lab 01 Forms in excel Tahani ALdweesh 1. 1. Insert form into your project. 2. Change form’s properties. 3. Put controls on the form. 4. Change controls’

Slides:



Advertisements
Similar presentations
Working with Intrinsic Controls and ActiveX Controls
Advertisements

Using Macros and Visual Basic for Applications (VBA) with Excel
Tutorial 8: Developing an Excel Application
AE6382 VBA - Excel l VBA is Visual Basic for Applications l The goal is to demonstrate how VBA can be used to leverage the power of Excel u VBA syntax.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
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.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
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.
Welcome to Transforming PowerPoint: Creating an Interactive Environment using VBA Log onto computer Open Internet Explorer URL -
VBA & Excel Barry L. Nelson IEMS 465 Fall Quarter 2003.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Variables and Constants
Chapter 3: Using Variables and Constants
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module M Programming in Excel with VBA.
© McGraw-Hill Companies, Inc., McGraw-Hill/Irwin Extended Learning Module M Programming in Excel with VBA.
VBA for Excel. What is a spreadsheet? u An Excel spreadsheet is a set of worksheets  Each worksheets is made up of rows and columns of cells  Rows are.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module M Programming in Excel with VBA.
Tutorial 11 Using and Writing Visual Basic for Applications Code
Ch 11: Userforms CP212 Winter Topics Designing User Forms o Controls Setting Properties o Tab Order o Testing Writing Event Handlers o Userform_Initialize.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
Teacher: Ms. Olifer MICROSOFT VISUAL STUDIO 2010: PROPERTIES OF WINDOWS FORM OBJECT.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
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.
Lecture 8 Visual Basic (2).
Outline Software and Programming Program Structure Tools for Designing Software Programming Languages Introduction to Visual Basic (VBA)
VBA Lab 2 I ns.Samia Al-blwi. Visual Basic Grammar Object: Visual Basic is an object-oriented language. This means that all the items in Excel are thought.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
You can use Access forms to create an interface to your reports and queries. You can add: Buttons to initiate reports and queries Combo Boxes, List.
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.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Chapter 11: Introduction to VBA Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Types of Visual Basic Data Numeric Data Non Numeric Data.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Other Variable Types Dim lab as String makes a box that can store a label tag Dim ColHead As String ColHead = “function” ColHead function Dim lab as Boolean.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
Programming with Microsoft Visual Basic th Edition
Tutorial 3: Using Variables and Constants1 Tutorial 3 Using Variables and Constants.
Chapter 4 Getting Started with VBA. Subroutines Subroutine is the logical section of code that performs a particular task. Subroutine is also called a.
Variables in VB.NET. Variables  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can.
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
Understanding Visual Basic Fundamentals CHAPTER 13 Understanding Visual Basic Fundamentals.
COMPREHENSIVE Access Tutorial 11 Using and Writing Visual Basic for Applications Code.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 11 So Many Paths … So Little Time.
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
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.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Visual Basic Fundamental Concepts
A variable is a name for a value stored in memory.
VBA - Excel VBA is Visual Basic for Applications
VBA - Excel VBA is Visual Basic for Applications
Microsoft Office Illustrated
Excel VBA Day 3 of 3 Tom Vorves.
Microsoft Visual Basic 2005 BASICS
Visual Basic..
WEB PROGRAMMING JavaScript.
Data Types List Box Combo Box Checkbox Option Box Visual Basic 6.0
CHAPTER FOUR VARIABLES AND CONSTANTS
Variables and Constants
Presentation transcript:

Lab 01 Forms in excel Tahani ALdweesh 1

1. Insert form into your project. 2. Change form’s properties. 3. Put controls on the form. 4. Change controls’ properties. 5. Write code. 6. Use Show method to display the form. Tahani ALdweesh 2

VBA : Standard programming language for office programs. Can be used in any office applications in same way. As you do more work with VBA you will need to use VBE(Visual Basic Editor ), Tahani ALdweesh 3

:The Visual Basic Editor (VBE) is the environment in which you work with VBA programming code. Tahani ALdweesh 4

5 -Open Microsoft Excel - Tools > Macro > Visual Basic Editor (2003) ALT + F11.user form < -insert

Tahani ALdweesh 6 Project window properties window User Form Work Area

Project window: shows a hierarchical view of the contents of the current VBA project view  project explorer or Ctrl+R Properties window: shows the various properties available for whatever object that is highlighted view  Properties window or F4 User form window : the design area,the toolbox will appear by default insert  user form Code window: where the procedures take place view  code or F7 Work area: the rest of the VBE Tahani ALdweesh 7

Properties are the physical descriptions of all Excel objects, and the description of the particular property is called the value of the property. Contains detailed information about any selected part of a project in.the Project Explorer Tahani ALdweesh 8

9 ToolBox

Label: used to instruct the user Textbox: enables the user to enter textual info. List box: list of choices. Checkbox: allow you to choose more than one option. Combo box: is so named because it combines the function of textbox and a list box. Option buttons: restricts the user to one choice. Frame: used for: 1-groups option buttons 2-visually, arranging different portions of the form Tahani ALdweesh 10

In term of VB, variables are areas allocated by the computer memory to hold data. Like the mail boxes, each variable must be given a name. To name a variable in Visual Basic, you have to follow a set of rules. Tahani ALdweesh 11

variables The following are the rules when naming the :in Visual Basic It must be less than 255 characters. Must start with a letter (a to z, A to Z). It must not begin with a number. No spacing is allowed. Can contain any number of letters or digits (a digit is 0 to 9). Can contain the underscore. Tahani ALdweesh 12

Invalid nameValid name My.bookMy_book 1studentSchool *&fatherBoy_&hifather Tahani ALdweesh 13

Declaring Variables In Visual Basic, one needs to declare the variables before using them by assigning names and data types. They are normally declared in the general section of the codes' windows using the Dim statement. The format is as follows: Dim Variable Name As Data Type Tahani ALdweesh 14

Dim password As String Dim yourName As String Dim firstnum As Integer Dim secondnum As Integer Dim total As Integer Dim doDate As Date You may also combine them in one line, separating each variable with a comma, as follows: You may also combine them in one line, separating each variable with a comma, as follows: Dim password As String, yourName As String, firstnum As Integer Tahani ALdweesh 15

Constants are different from variables in the sense that their values do not change during the running of the program. Declaring a Constant Const Constant Name As Data Type = Value : Example Const Pi As Single=3.142 Const Temp As Single=37 Const Score As Single=100 Tahani ALdweesh 16

After declaring various variables using the Dim statements, we can assign :values to those variables. The general format of an assignment is Variable=Expression variable or a control property value The variable can be a declared variable or a control property value. mathematical expression, a number, a string, a Boolean value (true or false) and more. The expression could be a mathematical expression, a number, a string, a Boolean value (true or false) and more. Tahani ALdweesh 17

firstNumber=100 secondNumber=firstNumber-99 userName="John Lyan" userpass.Text = password Label1.Visible = True Command1.Visible = false Label4.Caption = textbox1.Text ThirdNumber = Val(usernum1.Text) total = firstNumber +secondNumber+ThirdNumber Tahani ALdweesh 18

Tahani ALdweesh 19

Private Sub CommandButton1_Click() Dim rad As Double rad = Val(TextBox1.Text) Dim area As Double area = 3.17 * rad * rad TextBox2.Text = area End Sub Private Sub CommandButton2_Click() UserForm1.Hide End Sub Tahani ALdweesh 20

Tahani ALdweesh 21