1 / 14

Visual Basic for Applications - The Environment

Visual Basic for Applications - The Environment. What is an event-driven program? A user interface? What are Access/Accelerator Keys? NOTE: Important material on VBA is in the Course Guide at the start of this lecture slide section, so read those pages soon!. What does it look like?.

donkor
Télécharger la présentation

Visual Basic for Applications - The Environment

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Visual Basic for Applications - The Environment • What is an event-driven program? • A user interface? • What are Access/Accelerator Keys? • NOTE: Important material on VBA is in the Course Guide at the start of this lecture slide section, so read those pages soon! CS 105 Spring 2010

  2. What does it look like? CS 105 Spring 2010

  3. Why Learn Visual Basic for Applications? • Widely used to create applications for the PC and to jazz up Windows, Browsers, etc. • Excel and Access can be modified by Visual Basic for Applications (VBA is built in, but will stop in the next version of Office) • FUN to do--you can see your results quickly CS 105 Spring 2010

  4. What is a software program? A series of instructions to the computer to do some task Right now, this computer is running a master program (Windows OS) controlling many smaller programs (Powerpoint) CS 105 Spring 2010

  5. Visual Basic for Applications: BASIC stands for Beginner’s All-purpose Symbolic Instruction Code. • Developed in the 1960s. Microsoft developedVisual Basicin 1991. • Lets you make stand-alone programs Visual Basicfor Applications • Allows you to program in Microsoft applications, to create or improve macros, to create user interfaces, and even make your own programs. CS 105 Spring 2010

  6. Programming Languages: Visual Basic for Applications • A program’s ability to respond to events • Forms the basis of event-driven programming • Responds to user-initiated events such as keystroke or click, or even opening up a workbook examples: Visual Basic for Applications, Java • Uses Objects such as command buttons, cells, pictures, charts, spreadsheets. CS 105 Spring 2010

  7. What is an Event? • An event is any action to an object that is recognized by an application such as Excel. • Opening or closing an Excel workbook • Clicking on a command button • Changing the data in a cell • An event procedure is code that runs in response to the event. CS 105 Spring 2010

  8. What does a procedure look like? Private Sub cmdCopy_Click() [F8].Value = [C8].Value End Sub CS 105 Spring 2010

  9. Calling Event Procedures You can run one procedure from another procedure. You "call" it, even if it is stored in another module/worksheet. You call a subprocedure by writing its name: Private Sub cmdRun_Click() cmdFormat_Click End Sub CS 105 Spring 2010

  10. Graphical User Interface • You create the GUI (graphical user interface)/ CHI (computer-human interface) You create prompts, questions to the user Key entry, Mouse Click, Menu Selection, Text or data entry You decide the program responses to user actions Including Computations, Change of Interface, etc. CS 105 Spring 2010

  11. What happens when you use VBA • You create Input Boxes or use controls to gain input from the user. • You insert code behind spreadsheet, in the VISUAL BASIC EDITOR, to process the information. • The basic building block of a VBA program is the procedure (subroutine = sub procedure = sub) CS 105 Spring 2010

  12. Assignment Statement • [cell reference].Value = expression • Example 1: [B3].Value = 9 • Meaning: The new value of cell B3 is 9 • Example 2: [B3].Value = [B3].Value + 9 • Meaning: The new value of cell B3 is the old • value of cell B3 plus 9 • The =means "take the value on the right side and assign it tothe cell on the left side" CS 105 Spring 2010

  13. A FLAWED assignment statement 33 = [B3].Value CS 105 Spring 2010

  14. To summarize: What is • an event-driven program? • a user interface? • an assignment statement? CS 105 Spring 2010

More Related