Mastering. Visual Basic

Similar documents
Guide to Teaching Computer Science

THE UNIVERSITY OF TEXAS RIO GRANDE VALLEY GRAPHIC IDENTITY GUIDELINES

Genre Trajectories. Identifying, Mapping, Projecting. Garin Dowd. Natalia Rulyova. Edited by. and. University of West London, UK

LEGO MINDSTORMS Education EV3 Coding Activities

Course Groups and Coordinator Courses MyLab and Mastering for Blackboard Learn

EDEXCEL FUNCTIONAL SKILLS PILOT TEACHER S NOTES. Maths Level 2. Chapter 4. Working with measures

Developing Grammar in Context

CHANCERY SMS 5.0 STUDENT SCHEDULING

PowerTeacher Gradebook User Guide PowerSchool Student Information System

International Series in Operations Research & Management Science

Excel Formulas & Functions

Perspectives of Information Systems

MMOG Subscription Business Models: Table of Contents

Learning Microsoft Publisher , (Weixel et al)

THE PROMOTION OF SOCIAL AWARENESS

K-12 Blueprint Logo Placement

Appendix L: Online Testing Highlights and Script

Training Catalogue for ACOs Global Learning Services V1.2. amadeus.com

Ruggiero, V. R. (2015). The art of thinking: A guide to critical and creative thought (11th ed.). New York, NY: Longman.

Houghton Mifflin Online Assessment System Walkthrough Guide

Advanced Grammar in Use

Longman English Interactive

CODE Multimedia Manual network version

Beginning Blackboard. Getting Started. The Control Panel. 1. Accessing Blackboard:

Instrumentation, Control & Automation Staffing. Maintenance Benchmarking Study

My First Spanish Phrases (Speak Another Language!) By Jill Kalz

PeopleSoft Human Capital Management 9.2 (through Update Image 23) Hardware and Software Requirements

Lecture Notes on Mathematical Olympiad Courses

Learning Microsoft Office Excel

WiggleWorks Software Manual PDF0049 (PDF) Houghton Mifflin Harcourt Publishing Company

Practical Research Planning and Design Paul D. Leedy Jeanne Ellis Ormrod Tenth Edition

GACE Computer Science Assessment Test at a Glance

Field Experience Management 2011 Training Guides

BPS Information and Digital Literacy Goals

Using Virtual Manipulatives to Support Teaching and Learning Mathematics

Session Six: Software Evaluation Rubric Collaborators: Susan Ferdon and Steve Poast

To link to this article: PLEASE SCROLL DOWN FOR ARTICLE

Information for Candidates

Pragmatic Use Case Writing

MARE Publication Series

SER CHANGES~ACCOMMODATIONS PAGES

Spoken English, TESOL and Applied Linguistics

STUDENT MOODLE ORIENTATION

SEPERAC MEE QUICK REVIEW OUTLINE

TeacherPlus Gradebook HTML5 Guide LEARN OUR SOFTWARE STEP BY STEP

On Human Computer Interaction, HCI. Dr. Saif al Zahir Electrical and Computer Engineering Department UBC

SPRING GROVE AREA SCHOOL DISTRICT

Rover Races Grades: 3-5 Prep Time: ~45 Minutes Lesson Time: ~105 minutes

Business Finance in New Zealand 2004

Tap vs. Bottled Water

DOCTORAL SCHOOL TRAINING AND DEVELOPMENT PROGRAMME

READ 180 Next Generation Software Manual

Introduction to Moodle

Read&Write Gold is a software application and can be downloaded in Macintosh or PC version directly from

SCT Banner Student Fee Assessment Training Workbook October 2005 Release 7.2

MyUni - Turnitin Assignments

Student Handbook. This handbook was written for the students and participants of the MPI Training Site.

A Practical Introduction to Teacher Training in ELT

Physics 270: Experimental Physics

Learning Lesson Study Course

ITSC 2321 Integrated Software Applications II COURSE SYLLABUS

Basic German: CD/Book Package (LL(R) Complete Basic Courses) By Living Language

Grade 3: Module 2B: Unit 3: Lesson 10 Reviewing Conventions and Editing Peers Work

BOOK INFORMATION SHEET. For all industries including Versions 4 to x 196 x 20 mm 300 x 209 x 20 mm 0.7 kg 1.1kg

Excel Intermediate

Bluetooth mlearning Applications for the Classroom of the Future

Adaptations and Survival: The Story of the Peppered Moth

Education for an Information Age

Qualification handbook

TotalLMS. Getting Started with SumTotal: Learner Mode

Bitstrips for Schools: A How-To Guide

Moodle Student User Guide

MOODLE 2.0 GLOSSARY TUTORIALS

AP Proctor Training. Setting the Tone. Materials Needed for the Training. Proctor Duties. Proctor Training Instructions

Dialogue Live Clientside

Office Hours: Day Time Location TR 12:00pm - 2:00pm Main Campus Carl DeSantis Building 5136

Urban Analysis Exercise: GIS, Residential Development and Service Availability in Hillsborough County, Florida

Outreach Connect User Manual

Cambridge NATIONALS. Creative imedia Level 1/2. UNIT R081 - Pre-Production Skills DELIVERY GUIDE

TIMSS ADVANCED 2015 USER GUIDE FOR THE INTERNATIONAL DATABASE. Pierre Foy

Test Administrator User Guide

21st CENTURY SKILLS IN 21-MINUTE LESSONS. Using Technology, Information, and Media

Louisiana Free Materials List

Intel-powered Classmate PC. SMART Response* Training Foils. Version 2.0

ENGINEERING FIRST YEAR GUIDE

ACCOUNTING FOR LAWYERS SYLLABUS

Timeline. Recommendations

K-12 PROFESSIONAL DEVELOPMENT

IMPLEMENTING EUROPEAN UNION EDUCATION AND TRAINING POLICY

The Keele University Skills Portfolio Personal Tutor Guide

Idaho Public Schools

Audit Of Teaching Assignments. An Integrated Analysis of Teacher Educational Background and Courses Taught October 2007

Unit purpose and aim. Level: 3 Sub-level: Unit 315 Credit value: 6 Guided learning hours: 50

Higher Education / Student Affairs Internship Manual

Information for Private Candidates

Using SAM Central With iread

Fountas-Pinnell Level P Informational Text

University of Phoenix - Office of Student Services and Admissions - Course Transfer Guide Harford Community College

Following Directions. Table of Contents

International Advanced level examinations

Transcription:

Mastering 0 Visual Basic

Macmillan Master Series Accounting Advanced English Language Advanced Pure Mathematics Arabic Banking Basic Management Biology British Politics Business Administration Business Communication Business Law C Programming Catering Theory Chemistry COBOL Programming Communication Databases Economic and Social History Economics Electrical Engineering Electronic and Electrical Calculations Electronics English as a Foreign Language English Grammar English Language English Literature French French 2 German German 2 Global Information Systems Human Biology Internet Italian Italian 2 Japanese Manufacturing Marketing Mathematics Mathematics for Electrical and Electronic Engineering Modern British History Modern European History Modern World History Pascal Programming Philosophy Photography Physics Psychology Science Social Welfare Sociology Spanish Spanish 2 Spreadsheets Statistics Study Skills Visual Basic W ord Processing Macmillan Master Series Series Standing Order ISBN 978-0-333-69343-8 Y ou can receive future titles in this series as they are published by placing a standing order. Please contact your bookseller or, in case of difficulty, write to us at the address below with your name and address, the title of the series and the ISBN quoted above. Customer Services Department, Macmillan Distribution Ltd Houndmills, Basingstoke, Hampshire RG2l 6XS

o Mastering Visual Basic Stephen Saxon and Diane Saxon Series Editor Timothy Davies Computer Consultant MACMIUAN

Stephen Saxon and Diane Saxon 1997 All rights reserved. No reproduction, copy or transmission of this publication may be made without written permission. No paragraph of this publication may be reproduced, copied or transmitted save with written permission or in accordance with the provisions of the Copyright, Designs and Patents Act 1988, or under the terms of any licence permitting limited copying issued by the Copyright Licensing Agency, 90 Tottenham Court Road, London WIP 9HE. Any person who does any unauthorised act in relation to this publication may be liable to criminal prosecution and civil claims for damages. The authors have asserted their rights to be identified as the authors of this work in accordance with the Copyright, Designs and Patents Act 1988. First published 1997 by MACMILLAN PRESS LTD Houndmills, Basingstoke, Hampshire RG21 6XS and London Companies and representatives throughout the world ISBN 978-0-333-69599-9 ISBN 978-1-349-14525-6 (ebook) DOI 10.1007/978-1-349-14525-6 A catalogue record for this book is available from the British Library. This book is printed on paper suitable for recycling and made from fully managed and sustained forest sources. 1098765 06 05 04 03 02 01 432 1 00 99 98 97 Copy-edited and typeset by Povey-Edmondson Tavistock and Rochdale, England

Ocontents Preface Acknowledgements Conventions IX xi xii 1 Introduction to Visual Basic 1 What do you need to get started? 1 What is Visual Basic? 2 Summary 3 2 Finding your way around 4 Getting started 4 Customizing the display 5 Parts of the screen display 8 Visual Basic Help 13 Summary 16 3 Using forms 17 What is a form? 17 Introduction to properties 18 Running the pro gram 20 Designing your form 21 Setting form properties 22 Summary 23 4 Working with projects 24 What is a project? 24 The Project Explorer window 24 Saving a project 25 Opening a project 27 Opening more than one project 27 Starting a new project 28 Running a project 29 Printing a project 30 Summary 31 CONTENTS v

5 Exploring controls 32 What is a control? 32 Placing controls on a form 32 Labels 37 Text boxes 44 Command buttons 46 Focus 48 Naming conventions 49 Summary 51 6 Adding code 52 What is code? 52 The code window 53 Writing code 55 Using he1p when programming 59 Summary 61 7 Increasing control 62 Check boxes 62 Option buttons 63 List boxes 66 Combo boxes 71 Scroll bars 72 Timer control 75 Summary 77 8 Doing more with code 78 Making decisions 78 Ifcommand 78 Message boxes 81 Select case statement 83 Storing information 84 Data types 87 Constants 88 Making your code easier to read 89 Summary 91 9 Starting to function 92 What are functions? 92 Mathematical functions 93 Date and Time functions 93 Color functions 94 Generating random numbers 97 Message boxes and Input boxes 99 Changing data type 103 Manipulating strings 104 Summary 107 vi CONTENTS

10 Drawing with controls 108 Line contro1 108 Shape contro1 112 Pictures in Visua1 Basic 115 The Image contro1 115 Picture box contro1 117 Frame contro1 118 Summary 121 11 Going round in circles 122 Looping in Visua1 Basic 122 For... Next 100ps 122 Interrupting 100ps 124 Do... Loop 125 Summary 128 12 Making it work 129 Syntax checking 129 Compi1e checking 130 Run-time errors 131 Stopped and paused projects 132 Debugging whi1e running 132 A voiding errors 135 Summary 136 13 Drawing without controls 137 Container contro1s 137 Drawing dots 138 Drawing 1ines 140 Drawing rectang1es 142 Drawing circ1es 143 Print method 144 AutoRedraw 144 Summary 146 14 Adding menus 147 Creating menus 147 The Menu Editor 147 Adding options to menus 149 Keyboard contro1 151 Adding code to menus 154 Advanced features 155 Summary 156 15 Arrays 157 Control arrays 157 Variable arrays 160 Summary 163 CONTENTS vii

16 Using more than one form 164 Adding additional forms 164 Switching between forms 165 Displaying forms 166 Start-up form 167 Accessing properties 168 Availability of variables 169 Summary 169 17 Subroutines, functions and modules 170 Subroutines 170 Functions 173 Modules 177 Summary 182 18 Putting it ail together 183 Planning a project 183 The Hangman project 184 A solution 190 19 Practising your skills 192 Stop watch 192 Spinning image 194 Name reversal 196 Noughts and crosses 198 Appendix A: Books Online 200 Appendix B: Creating EXE files from projects 203 Appendix C: Visual Basic web sites 206 Index 208 viii CONTENTS

Opreface This new book in the Macmillan Mastering Series provides the essential skills needed to produce applications in the Microsoft Visual Basic language. The book builds up the necessary skills by introducing features in a logical way and providing opportunities to try them out. The features and methods are explained in easy to follow language with illustrations and graphics to help you on your way. Each chapter contains a variety of practical tasks which allow you to apply and develop your new skills. The book is not intended to be just be another reference book - there are many perfectly good reference sources available and the on-line help available within the package is an excellent resource. The book uses a practical approach, developing the basic skills first then moving on to more advanced topics. Each chapter introduces new ideas and shows how these are used. Opportunities are provided for you to apply and practise your skills in a variety of tasks at strategie points. Practising your new skills is an important part of ensuring that you have understood the material in the chapter and helps to avoid confusion due to having too much information to process at once. Who Is this book for? This book is for you! It is suitable for anyone who wants to learn how to write programs which run under Windows. Whether you are a horne user interested in writing your own programs quickly and easily or if you are a student, this book will help you though the stages of building an application. It is suitable for students who are studying Visual Basic as part of a computing or information technology course. The book can be used by students on a variety of courses and levels who want to learn to program in Windows or are looking for extra material and perhaps a different approach to increase their understanding. Visual Basic is now present in many courses as an addition or an alternative to traditional programming. For example, it is included in GNVQ Advanced Information Technology as an additional unit and is found on many higher level courses (HNC, HND and degree level) in Business IT and Computing. Many local centres run programming courses and they are increasingly switching to Visual Basic as PREFACE ix

being the new environment for developers. City & Guilds of London provide accreditation for Visual Basic programming through their 7261 Information Technology programme. As you reach the end of this book you will have gained asound footing in Visual Basic programming. We hope you will have found the journey challenging and fun and will wish to continue learning and developing in Visual Basic. STEPHEN SAXON DIANE SAXON x PREFACE

o Acknow'edgements The authors would like to thank our editor, Tim Davies, for his suggestions and support and Mark Saxon for checking and reading chapters. Grateful thanks are also given to Microsoft and Text 100 for providing copies of Microsoft Visual Basic software Trademarks: Microsoft Windows, Windows 95, Visual Basic are registered trademarks of Microsoft Corporation. All brand names and product names used in this publication are trademarks, registered trademarks or tradenames of their respective holders. Screen shots are reprinted with permission from Microsoft Corporation. Screen shots are captured and edited using lasc Paintshop Pro. ACKNOWLEDGEMENTS xi

o Conventlons bold italic typeface B practice menu options new terms, first time they are introduced commands and functions tasks points to note xii CONVENTIONS