chap12 - QBASIC Chapter 12 QBASIC Chapter 12 An...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: QBASIC Chapter 12 QBASIC Chapter 12 An Introduction to Visual Basic Created by Richard D. Taylor Illustrated by Saundra J. Taylor What is Visual Basic? What is Visual Basic? ­ A Windows application that helps to build Windows special-purpose Windows applications special-purpose ­ Primer edition - included with the textbook Primer and two limitations: and ­on-line facility is not available ­the ability to convert Visual Basic programs to the executable files that run outside of Visual Basic is not available is The Three­Step Approach to Building The Three­Step Approach to Building Applications with Visual Basic ­ Design time - the period of time during Design which applications are built which ­ Run time - the time during which the Run completed application is actually functioning functioning ­ Three Steps: Create the interface; Set Three properties; Write code properties; The Three­Step Approach to Building The Three­Step Approach to Building Applications with Visual Basic Installing the Visual Basic Primer Edition ­ Create the Interface ­Form - the container for different components Form of the interface of ­Objects or Controls - can be added to a form Objects during design time and during run time during ­Controls - are added during design time by Controls using the Toolbox to draw the controls on the form form The Three­Step Approach to Building The Three­Step Approach to Building Applications with Visual Basic Installing the Visual Basic Primer Edition ­The Three-Step Approach to Building Applications The with Visual Basic Installing the Visual Basic Primer Edition Toolbox - a window in the Visual Basic Edition environment that displays icons representing all of the controls that are available the ­Custom Controls - additional controls are supplied Custom with the Professional edition of Visual Basic with The Three­Step Approach to Building The Three­Step Approach to Building Applications with Visual Basic Installing the Visual Basic Primer Edition ­ Set Properties - characteristics or attributes Set of a control such as color and size of ­Object-oriented Programming System (OOPS) Object-oriented - structure of objects and properties structure The Three­Step Approach to Building The Three­Step Approach to Building Applications with Visual Basic Installing the Visual Basic Primer Edition ­Properties Windows - properties are set at design Properties time and during runtime through code statements in a properties window Properties windows consists of three sections: three Object box - shows the name of the control whose Object properties are being set properties ­ Settings box - is where you enter a value for a specific Settings property, or choose from a set of predefined property values that display as a drop-down list values ­ Properties list - is the set of properties that belong to the Properties selected control and the current values of those properties selected ­ The Three­Step Approach to Building The Three­Step Approach to Building Applications with Visual Basic Installing the Visual Basic Primer Edition ­ Write Code - set of actions called events Write that can occur during run time These include such actions as clicking the mouse or pressing a key on the keyboard or ­ Procedures - subroutines similar to ones Procedures you’ve written in earlier chapters in QBASIC QBASIC The Three­Step Approach to Building The Three­Step Approach to Building Applications with Visual Basic Installing the Visual Basic Primer Edition ­ Procedural Language - nothing happens in a Procedural Visual Basic application until an event occurs ­ Visual Basic is Event-driven ­ Methods - a subroutine or a function that Methods operates on an object - it is invoked through a code statement consisting of the control’s name, a period, and the method name, The Three­Step Approach to Building The Three­Step Approach to Building Applications with Visual Basic Installing the Visual Basic Primer Edition ­ Functions - supports functions that you Functions create and also has library of approximately 100 built-in functions 100 Installing the Visual Basic Installing the Visual Basic Primer Edition ­ Start Windows and choose Run…from the Start File menu in Windows Program Manager File ­ Insert the Visual Basic diskette that comes Insert with the textbook in drive A with ­ Type: a:setup in the command line box and Type: choose the ok button choose The Visual Basic Environment The Visual Basic Environment ­ Setting up the Windows Environment: ­Close or minimize any application windows that are Close currently open except Program Manager currently ­Double-click the Visual Basic program - item icon Double-click in the Visual Basic Program Group Window in ­Make Program Manager the active window by Make clicking on its window or selecting it from the Task Manager (Alt + Tab) Manager The Visual Basic Environment The Visual Basic Environment ­Click the Minimize button in the Program Click Manager window ­Program Manager is minimized, and the Program desktop now displays five windows that make up the Visual Basic programming environment up The Visual Basic Environment The Visual Basic Environment ­ Visual Basic windows are made active in Visual one of three ways: one ­Clicking on the window if it is visible on the Clicking desktop desktop ­Double-clicking its icon if it is minimized ­Choosing the window’s name from the Choosing Window minimizes the Visual Basic menu bar Window Building a Currency Conversion Building a Currency Conversion Application ­ When the user clicks one of the four buttons When that are labeled with different currencies, the dollar amount is converted to the appropriate currency and appears in a box with the corresponding label with Creating the Interface for the Creating the Interface for the Currency Conversion Application ­Projects - the applications that you build, a Projects project always begins with a form project ­Run Time - a form becomes the windows that Run the application occupies on the desktop the ­ Positioning a Form ­Form’s position on the desktop is set by Form’s dragging the form to the desired location dragging ­Form’s position can be changed as often as Form’s desired during the design time desired Creating the Interface for the Creating the Interface for the Currency Conversion Application ­ Adding and Removing controls ­Controls are added to a form by using the Controls Visual Basic window called the Toolbox Visual ­Controls can be made larger or smaller by Controls dragging the handles located around the control dragging ­Controls can be removed from the form Creating the Interface for the Creating the Interface for the Currency Conversion Application ­ Changing the Location and Size of Controls ­The location given to a control by dragging and The dropping it on a form during the design time is the location that the control will have at the beginning of run time ­A control’s location can be changed during run control’s time by using code statements that change its Top and Left properties Top Setting Properties for the Setting Properties for the Currency Application ­ The Caption Property The ­contains text that you want to appear on the contains control control ­ The Text Property The ­a text box is similar to the Caption property of text a label, whatever value you give to the Text property of a text box control will appear in the text box at the beginning of run time text Setting Properties for the Setting Properties for the Currency Application ­ The BorderStyle Property ­The default is no border, the BorderStyle will add a The border border ­ The Name Property ­Visual Basic assigns unique default names to controls, such Visual as Form1, Label1, Label2 as ­The Name of the control and the Caption of the Control are The two different properties two ­Forms are named by setting the Name Property of the form Forms control control Writing Code for the Currency Writing Code for the Currency Conversion Application ­ You began the Currency Application by You building the user interface, consisting of a form and control form ­ You then set the properties of the controls ­ The remaining step is to write the event The procedures that will occur within the application application Saving a Visual Basic Project Saving a Visual Basic Project ­ Save your project periodically while you are Save working on it and always before running it working ­ Projects are saved as a set of files, forms are saved Projects as files with a file name and an .frm extension as ­ Visual Basic creates an additional file to save the Visual project with an extension .mak project ­ Common dialog boxes - file save and project save Common boxes are the same in many different Window applications applications Starting, Opening, and Running Starting, Opening, and Running Projects ­ Starting a New Project ­When you start Visual Basic, a new project is opened When automatically automatically ­ Opening a Project ­Once a project has been saved, you can return to the project Once and make any changes that you want and ­ Running an Application ­You will run your application from within the Visual Basic You environment environment ­You do not need to start the application over each time you You want to do another conversion want Exiting Visual Basic Exiting Visual Basic ­ You exit Visual Basic just as you would in You any other Windows Application any Summary Slide Summary Slide ­ What is Windows? ­ What is Visual Basic? ­ The Three-Step Approach to Building The Applications with Visual Basic Applications ­ Installing the Visual Basic Primer Edition ­ Building a Currency Conversion Building Application Application Summary Slide Summary Slide ­ Creating the Interface for the Currency Creating Conversion Application Conversion ­ Setting Properties for the Currency Setting Application Application ­ Writing Code for the Currency Conversion Writing Application Application ­ Saving a Visual Basic Project ­ Starting, Opening, and Running Projects ...
View Full Document

Ask a homework question - tutors are online