Wrox Home  
Search
VBScript Programmer's Reference

ISBN: 0764543679

Back to current edition: VBScript Programmer's Reference, 2nd Edition

Download Code  |  Errata
Chapter Page Details Date Print Run
28 Trim()

The code on page 28 will not remove any additional spacing. A better example of the code, which will remove any additional spacing and not allow empty strings, is:

Dim Greeting
Dim UserName
Dim TryAgain

Do
TryAgain = "No"

UserName = InputBox("Please enter your name:")
UserName = Trim(UserName)
If UserName = "" Then
MsgBox "You must enter your name."
TryAgain = "Yes"
Else
Greeting = "Hello, " & UserName & ", it's a pleasure to meet you."
End If

Loop While TryAgain = "Yes"

MsgBox Greeting

26-Jan-00 1
35 Organizing and Reusing Code

2nd Paragraph, 4th Sentence should read:

Before we start the loop, we initialize LoopCount with the numeric value of one.

19-Apr-00 1
76 What is a Literal?

The text should read:

A literal is any piece of data that appears in your code that is not stored as a variable or named constant...

09-Feb-00 1
140 WroxLogGroup.vbg

The code referred to as 'WroxLogGroup.vbg' is called 'page140.vbs' in the downloadable source code.

13-Jan-00 1
174 Using COM Components and Objects

The code should read:

<BLUE>Dim objFirstDocument
Dim objSecondDocument

' Instantiate the Document class from the Word COM
' component/server on the local machine
Set objFirstDocument = CreateObject("Word.Document")
' Let the second document reference the first document
Set objSecondDocument = objFirstDocument
' Show the instance of Word
objSecondDocument.ActiveWindow.Visible = True

' Destroy the first document after use
ObjFirstDocument.Close
Set objFirstDocument = Nothing


<BLACK>NOTE: "<RED>Set<BLACK>" has been deleted from line 10 of the code.

15-Dec-99 1
202 RegExp (use of "\b" , word boundary)

Paragraph 3 should read:

"... Without this the word 'National' would be changed to 'Nationanal'. Second..."

19-Jan-00 1
615 FileSystemObject object

The syntax for the following methods of the FileSystemObject object are listed incorrectly in Appendix F. The correct syntax for these methods is:

object.CopyFile source, destination[, overwrite]

object.CopyFolder source, destination[, overwrite]

object.DeleteFile filespec[, force]

object.DeleteFolder folderspec[, force]

object.MoveFile source, destination

object.MoveFolder source, destination

where [] indicate optional parameters

10-Jan-00 1