|  | Click Here!

Search the site:
EXPERT SEARCH

| Programming Languages
| Databases
| Security
| Web Services
| Network Services
| Middleware
| Components
| Operating Systems
| User Interfaces
| Groupware & Collaboration
| Content Management
| Productivity Applications
| Hardware
| Fun & Games

EarthWeb sites
Crossnodes
Datamation
Developer.com
DICE
EarthWeb.com
EarthWeb Direct
ERP Hub
Gamelan
GoCertify.com
HTMLGoodies
Intranet Journal
IT Knowledge
IT Library
JavaGoodies
JARS
JavaScripts.com
open source IT
RoadCoders
Y2K Info

# VBScript™
UNLEASHED

Petroutsos, Schongar, et al.

CONTENTS

## Chapter 1 Introducing HTML Scripting

- Introduction
- Designing Web Pages
- Definitions
- First Things First-HTML
  - The <`HEAD>` Tag
  - The <`TITLE>` Tag
  - The <`BODY>` Tag
  - Headings
  - Paragraphs
  - The `<FONT>` Tag
  - Links in Your Documents
  - Graphics
  - Multimedia in HTML
  - Tables
  - Forms in HTML
  - Using CGI Scripts in HTML
  - Other HTML Tags
  - Frames
- Scripting
- Objects
- ActiveX Controls
- Review

## Chapter 2 The VBScript Language

- Introduction
- Differences Between Visual Basic and VBScript
- Programming in VBScript
  - Creating a Test Page
  - What a Program Is
  - Concepts You Should Understand: Variables and Procedures
  - The Anatomy of VBScript Code
- Data Types
  - Subtypes of Variant Types
  - Using Variables
  - Constants
- Program Flow
  - Operators
  - Decision-Making in Programs
  - `If...Then...Else`
  - `For...Next`
  - `Do...Loop`
  - `For Each...Next`
  - `While...Wend`
- Review

## Chapter 3 VBScript Functions

- Introduction
- Procedures in Scripts
  - `Sub` Procedures and `Function` Procedures
  - Arguments to Procedures
  - Creating and Calling Functions
- Intrinsic Functions
- Basic Functions
  - `InputBox`
  - `len`
  - `MsgBox`
  - `VarType`
- String Functions
  - `Asc`
  - `Chr`
  - `InStr`
  - `LCase`
  - `Left`
  - `LTrim`
  - `Mid`
  - `Right`
  - `RTrim`
  - `Str()`
  - `StrComp`
  - `String`
  - `Trim`
  - `UCase`
  - `Val`
- Conversion Functions
  - `CByte`
  - `CDbl`
  - `CInt`
  - `CLng`
  - `CStr`
  - `CVErr`
- Math Functions
  - `Abs`
  - `Array`
  - `Atn`
  - `Exp`
  - `Hex`
  - `Int`
  - `Fix`
  - `Log`
  - `Oct`
  - `Rnd`
  - `Sgn`
  - `Sqr`
  - `Sin`
  - `Tan`
- Time and Date Functions
  - `Date`
  - `DateSerial`
  - `DateValue`
  - `Day`
  - `Hour`
  - `Year`
  - `Weekday`
  - `Minute`
  - `Month`
  - `Now`
  - `Second`
  - `Time`
  - `TimeSerial`
  - `TimeValue`
- Boolean Functions
- Review

## Chapter 4 Intrinsic Controls

- Introduction
- Events in VBScript
- Messages in a GUI Environment
- Placing Controls in HTML
- Intrinsic Controls
  - Button
- Checkbox
  - `Hidden`
  - `Text`
  - Textarea
- Select
- Using Controls in Your Documents
- Review

## Chapter 5 VBScript in Web Pages

- Using VBScript and HTML
  - Using the `onLoad` Event
  - Embedding VBScript in the HTML
  - Creating a New Page with VBScript
- Using VBScript and CGI/ISAPI
- Providing Database Access
  - Defining an ODBC Datasource
  - Creating the IDC Script File
  - Creating the Output Template File
  - Viewing the Results
- Review

## Chapter 6 The Scripting Model

- Windows, Documents, and Frames
  - The `window` Object's Properties
  - Methods
- The `document` Object
  - The `document` Object's Properties
  - The `document` Object's Methods
- Using the `document` Properties and Methods
  - A Self-Modifying Document
  - Color Cycling
  - A Yearly Calendar
- The `history` Object
  - The `HistoryObject` Project
- The `navigator` Object
  - The BrowserInfo Project
  - The NavigatorObject Project
- The `location` Object
  - The `LocationObject` Project
- The `link` Object
  - The LinksObject Project
- Review

## Chapter 7 Using ActiveX Controls

- Looking at a Brief History of Custom Controls
- Examining the Anatomy of an ActiveX Control
- Registering Your ActiveX Controls
- Putting an ActiveX Control in Your Web Page
- Installing and Distributing ActiveX Controls
- Examining ActiveX Controls
  - Animated Button Control
  - Chart Control
  - Label
  - Popup Menu Control
  - Preloader Control
  - StockTicker Control
  - Timer Control
- Using Third-Party Controls
- Using Signed Controls
- Creating ActiveX Controls
  - Using the Control Wizard to Create the Skeleton Files
  - Compiling a Control
  - Registering Your Control
  - Testing Your Control
- Creating Non-MFC ActiveX Controls
- Signing Your Objects for Internet Use
- Review

## Chapter 8 The ActiveX Control Pad

- Taking a Tour of the ActiveX Control Pad
  - Text Editor
  - Object Editor
  - Page Editor
  - Script Wizard
- Using ActiveX Controls
- Creating VBScript with the Script Wizard
- Using HTML Layouts
- Looking at the Available Controls
- Adding Controls to the Toolbox
- Creating Interactive Content
- Using VBScript with ActiveX Layouts
- Review

## Chapter 9 More ActiveX Controls

- The Popup Menu and Menu Controls
  - The Popup Menu
  - The Menu Control
  - The Popup Window Control
  - The Marquee Control
  - The Chart Control
  - The Chart Example
- Review

## Chapter 10 Error Handling

- Handling Errors in Your VBScript Pages
  - Syntax Errors
  - Errors with ActiveX Controls
  - Runtime Errors
- Coding to Avoid Errors
  - Using the ActiveX Control Pad
  - Using `Option` `Explicit`
  - Using Coding Conventions
- Coding to Handle Errors
  - Specifying Error Trapping
  - Using the `Err` Object
- Looking at Examples of Error Handling
  - Trapping Runtime Errors
  - Using the `Raise` Method
- Review

## Chapter 11 Optimizing Code

- Organizing Your Code
  - Chaos Theory 101
  - Code Behind the Scenes
- Error Checking and Debugging
- Use of Functions and Syntax
  - Variables Versus References
  - Data Types
- ActiveX Controls
  - Quality, Not Quantity
  - Divide and Conquer
- Development Tools
  - Still Using a Text Editor?
  - ActiveX Control Pad
  - Visual Basic to VBScript Converters
  - Future Integrated Development Environments?
- Review

## Chapter 12 Debugging

- Handling VBScript Errors
  - Syntax Errors: Say What You Mean!
  - Semantic Errors: Mean What You Say!
- Using Simple Debugging Techniques
  - Using the `MsgBox` Statement
  - Using the `On` `Error` `Resume` `Next` Statement
  - Using the `Err` Object
  - Taking the `Err` Object Further
- Using Advanced Debugging Techniques
  - Tracing Your Code Using the Message Box
  - Saturating Your Code with the Message Box
  - Watching Your Code Using Variables and the Message Box
  - Breaking Apart Complex Statements to Find Bugs
- Using Other Tools to Help You with the Debugging Task
- Using VBScript Versus Traditional Debugging Environments
- Using Visual Basic to Debug VBScript Applications
  - Using Visual Basic 4.0 Trace Capabilities
  - Debugging VBScript Code Within Visual Basic
- Handling HTML Errors
- Making Sure the Bugs Are Dead
- Creating Your Own Debug Window for Tracing
- Building Your Own Tracing Routines
- Looking at a Sample Variable Analysis Routine
- Looking at More Reasons Why VBScript Can Be Tough to Debug
- The Moral of the Story
- Review

## Chapter 13 Dynamic Web Page Building

- Using the Internet Explorer `Document` Object
  - Properties and Collections
  - Methods
- Using the ActiveX Timer Control
- Writing the Current Date and Time to the Page
- Creating a Random Frame Using Client-Side Refresh
- Changing the Document's Colors
- Using Cookies to Maintain User Information
- Review

## Chapter 14 Customize Your Web Page with Cookies

- Safety Considerations
- What Are Cookies?
  - Creating Cookies
  - How to Test Pages with Cookies
- The Cookie Folder
- Extracting the Cookie Values
- Review

## Chapter 15 Creating Active Documents for Corporate Intranets

- Client-Side Processing
- Distributed Applications
  - Databases
- Functionality and Flexibility
  - Native Document Hosting
  - Component Architecture
  - Third-Party Innovation
- Return on Investment (ROI)
  - Maintenance
  - Expansibility and Integration
  - Standards
  - Investment Protection
  - Employee Efficiency
  - Company Image
- Review

## Chapter 16 Controlling MS Office Documents in Web Pages

- ActiveX
- ActiveX Scripting
- ActiveX Control Pad
- Leveraging Your Investment
- Microsoft Office Suite
- Relevant Web Sites
- Review

## Chapter 17 Animation

- ActiveX Controls Capable of Animation
- Frame Animation with Image and Timer Controls
- Rotating Text with the Label Control
- Using Active Movie for Digital Audio and Video
- The Marquee Control for Scrolling Pages
- Other HTML Tags that Provide Multimedia Playback

## Chapter 18 VBScript and Java

- What Is Java?
- Java, Java Applets, and JavaScript
- Java Classes
- JavaScript Objects
- JavaScript Language Structure
  - JavaScript Operators
  - JavaScript Flow of Control Statements
- VBScript Language Structure
  - VBScript Examples
  - VBScript Variables
  - VBScript Operators
  - VBScript `Err` Object
  - VBScript Variant Data Type
  - VBScript Constants
  - VBScript Flow of Control Statements
  - VBScript Functions
  - VBScript Procedures
  - ActiveX
- Standards and Conventions
- Comparing Java, JavaScript, and VBScript: A Summary
- Examples
- Relevant Web Sites
- Review

## Chapter 19 VBScript and DLLs

- Static Versus Dynamic Library
- Structure of a DLL
  - The Entry Function
  - The `LibMain` Function
  - The `Exit` Function
- Programmer-Defined Functions
  - Exported Functions
  - Non-Exported (Internal) Functions
- Why Use DLLs?
- Disadvantages of Using DLLs
- A Sample DLL
- VBScript and DLLs
- Relevant Web Sites
- Review

## Chapter 20 CGI and VBScript

- Understanding CGI
- CGI Specification
- CGI Environment Variables
- Architecture of a CGI Application
- CGI Versus VBScript
- Examples
- Relevant Web Sites
- Review

## Chapter 21 Safety and Security

- A Matter of Trust…
  - Can VBScript Security Hold Up?
- VBScript's Built-In Safeguards
- Flirting with Danger-ActiveX Components
  - Authentic Controls-Friend or Foe?
  - Rogue Controls
  - Defending Against Friendly Fire and Nasties
- Paranoia, Self-Defense, and Reasonable Risk

## Chapter 22 VBScript as a Component in Other Applications

- Porting VBScript to VBA and Visual Basic
- All About ActiveX Scripting
  - Script Engines
  - Script Hosts
  - Communications Between Scripting Engines and Hosts
- Licensing
  - The Binary Route
  - Source Code
- Putting It All Together-Microsoft's "Spruuids" Example
- Future Hosts

## Chapter 23 Conversions and Calculations

- Metric Conversions
  - The User Interface
  - The `TabStrip` Control
  - Implementing the Conversions Utility
  - Programming the Application
- A Financial Calculator
  - The User Interface
- A Math Calculator
  - The User Interface
  - Programming the Application
  - Improving the Calculator
  - Further Improvements
- Review

## Chapter 24 WWW Personal Information Manager

- Overview
- How It Works
- Creating the Page
  - Working with Cookies
  - Creating Dynamic HTML
  - Presenting Information
  - Tying It All Together
- Review

## Chapter 25 Order Entry

- Ensuring Secure Transactions on the Web
  - Authenticating the Merchant
  - Authenticating the Purchaser
  - Encrypting Web Communications
- Reviewing Cookies
- Designing the Order Entry Form
- Creating the Order Entry Form
- Examining the VBScript Code
- Testing the Application
- Review

## Chapter 26 RTFEditor

- Using OCX Controls with VBScript
  - The RTFEditor Application
  - The Rich Textbox Control
  - Designing the User Interface
  - The Code Behind the Scenes
  - Saving and Recalling RTF Documents
- Review

## Chapter 27 The Chart and Grid Controls

- The Chart Example
- The GridChart Example
  - The Grid Control
  - Implementing the Application
- Review

## Appendix A VBScript Language Reference

- Variables, Constants, and Expressions
- Operators
  - Arithmetic Operators
  - Concatenation Operators
  - Logical Operators
  - Comparison Operators
- Statements
- Functions
  - Variable and Conversion Functions
  - Date/Time Functions
  - Conditional Functions
  - String Functions
  - Input Functions
  - Mathematical Functions

## Credits

Copyright © 1997 by Sams.net Publishing

### FIRST EDITION

All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. For information, address Sams.net Publishing, 201 W. 103rd St., Indianapolis, IN 46290.

International Standard Book Number: 1-57521-124-6

HTML conversion by :
M/s. LeafWriters (India) Pvt. Ltd.
Website : http://leaf.stpn.soft.net
e-mail : leafwriters@leaf.stpn.soft.net

#### Trademarks

All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams.net Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.

VBScript is a trademark of Microsoft Corporation.

Publisher and President: | Richard K. Swadley | Publishing Manager: | Greg Wiegand
Director of Editorial Services: | Cindy Morrow | Assistant Marketing Managers: | Kristina Perry, Rachel Wolfe
Acquisitions Editor | Christopher Denny | Development Editor | Anthony Amico
Software Development Specialist | Brad Myers | Production Editor | Mary Inderstrodt
Copy Editors | Heather Butler, Keith Davenport, Karen Letourneau | Indexer | Johnna VanHoose
Technical Reviewer | Greg Guntle | Editorial Coordinator | Katie Wise
Technical Edit Coordinator | Lynette Quinn | Resource Coordinator | Deborah Frisby
Editorial Assistants | Carol Ackerman, Andi Richter, Rhonda Tinch-Mize
Cover Designer | Gary Adair | Book Designer | Gary Adair
Copy Writer | Peter Fuller | Production Team Supervisor | Brad Chinn
Production | Sonja Hart, Michael Henry, Timothy Osborn, Gene Redding

### About the Authors

Bill Schongar and Paul Lagasse are the Senior Multimedia Developers at LCD Multimedia Creations, Inc., in Nashua, NH (`bills@lcdmultimedia.com` and `paull@lcdmultimedia.com`). Paul is an experienced Visual Basic programmer, with a design background that he's having fun putting to use in a variety of online endeavors. Bill somehow ended up in the computer industry, learning and teaching things about the online world, and contributing to other books such as CGI Programming Unleashed. Just don't ask Paul to recommend any movies, or Bill to show you how to juggle axes.

Evangelos Petroutsos has a M.S. degree in Computer Engineering and works as a freelance writer and consultant. He is the author of Interactive Web Publishing with Microsoft Tools and co-author of Visual Basic Power Toolkit.

Craig Eddy resides in Richmond, VA, with his wife and two children. Craig holds a B.S. in Electrical Engineering from Virginia Tech. He is currently employed as Senior Developer for Pipestream Technologies, Inc., where he is responsible for the continuing development of ContactBuilder and Sales Continuum. He is also the architect and chief programmer for the two-way synchronization between SQL Server and remote versions of Pipestream's sales force automation products. Craig specializes in Visual Basic, SQL Server, and Access development. He has been an author for Access 95`` Unleashed and Office 95 Unleashed, as well as being co-author of Web Programming with Visual Basic. Craig's hobbies include private business development and relaxing at the Outer Banks in North Carolina. Craig can be reached at `craige@richmond.infi.net`.

Keith Brophy is the Software Release Coordinator at X-Rite, Incorporated, and has had many years of experience in the design, development, and testing of software systems. In addition, he has taught advanced programming courses both at Grand Rapids Community College and Northern Virginia Community College. Keith has tech edited Real-World Programming with Visual Basic and co-authored Visual Basic 4.0 Performance Tuning and Optimization and Teach Yourself Visual Basic Script in 21 Days, both from Sams.

Owen Graupman has been working as a system integrator for various firms since he entered the workforce. A programmer by trade, he's written many custom financial applications using Visual Basic. He is currently employed as an independent consultant based in Los Angeles, California.

Brian Johnson is a freelance writer and programmer in Orlando, Florida. He has been involved in Internet development and Visual Basic programming for more than three years. You can usually find him answering questions in the Microsoft ActiveX newsgroups or find out more about him by hitting his Web site at `http://home.sprynet.com/sprynet/bjjohnson`.

Timothy Koets is a software engineer at X-Rite, Incorporated. He has extensive experience with Visual Basic, VBScript and Web Page development. He is currently teaching Advanced Visual Basic at Grand Rapids Community College. He also has experience with Visual C++, Delphi, Java, PowerBuilder and Lotus Notes. Timothy is the co-author of Visual Basic 4.0 Performance Tuning and Optimization and Teach Yourself Visual Basic Script in 21 Days, both from Sams.

### Tell Us What You Think!

As a reader, you are the most important critic and commentator of our books. We value your opinion and want to know what we're doing right, what we could do better, what areas you'd like to see us publish in, and any other words of wisdom you're willing to pass our way. You can help us make stronger books that meet your needs and give you the computer guidance you require.

Do you have access to CompuServe or the World Wide Web? Then check out our CompuServe forum by typing `GO SAMS` at any prompt. If you prefer the World Wide Web, check out our site at `http://www.mcp.com`.

NOTE
If you have a technical question about this book, call the technical support line at (800) 571-5840, ext. 3668.

As the publishing manager of the group that created this book, I welcome your comments. You can fax, e-mail, or write me directly to let me know what you did or didn't like about this book-as well as what we can do to make our books stronger. Here's the information:

FAX: | 317/581-4669
E-mail: | `programming_mgr@sams.mcp.com`
Mail: | Greg Wiegand Sams.net Publishing 201 W. 103rd Street Indianapolis, IN 46290

| Use of this site is subject certain Terms & Conditions. Copyright (c) 1996-1999 EarthWeb, Inc.. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Please read our privacy policy for details.