Errata

VB Language Developer's Handbook

Back to errata

Last updated 19 November 2001.

Chapter

Page

Where

Replace

With

1 (Added 11/2/2000)

84

Listing 1.21

' If there's more than one delimiter, map them
' all to the first one.

If Len(strDelimiter) > 1 Then
    strIn = dhTranslate(strIn, strDelimiter, _
  
     Left$(strDelimiter, 1))
End If

' If there's more than one delimiter, map them
' all to the first one.

If Len(strDelimiter) > 1 Then
    strIn = dhTranslate(strIn, strDelimiter, _
  
     Left$(strDelimiter, 1))
End If
strIn = dhTrimAll(strIn)

1 (Added 11/2/2000)

87

Listing 1.23

dhLastWord function

Public Function dhLastWord( _
 ByVal strText As String, _
 Optional ByRef strRest As String = "") As String

    Dim intCount As Integer
    Dim strTemp As String

    ' This is not quite so easy.
    ' Find the number of words, and then
    ' extract the final word.
    intCount = dhCountWords(strText)
    strTemp = dhExtractString(strText, intCount)

    ' Extract everything before the last word,
    ' and put that into strRest.
    strRest = Trim$(Left$(strText, _
     Len(strText) - Len(strTemp)))
    dhLastWord = strTemp
End Function

1 (Added 11/2/2000)

88

Beneath the Note section

The dhLastWord function is a bit different: It uses the built-in Split function to do its work. Because Split does its work more efficiently than dhExtractString does (as long as you’re interested in having the entire string parsed, which you are in this case), it makes sense to use this built-in function. Once the code removes all extraneous spaces, it can split the input string into words, and then return the final word in the array returned from Split:

astrItems = Split(strText)

strTemp = astrItems(UBound(astrItems))

The dhLastWord function is bit more complex, because the code must first find the number of words in the string, and then extract the correct one:

intCount = dhCountWords(strText)

strTemp = dhExtractString(strText, intCount)

9 (Added 1/31/2001

 

Not in book: in code samples

In the Font class, replace 

Public Size As Long

 

Public Size As Single

9 (Added 1/31/2001)

569

Listing 9.17

The Size member of the Font class needs to be a Single, not a Long integer, so that floating point sizes can be supported. Replace:

Dim intOldSize As Integer

and all references to intOldSize in this listing.

Dim sglOldSize As Single

All references of intOldSize should be replaced with sglOldSize.

9 (Added 1/31/2001)

 

Not in book: in code samples

NonClientMetrics.CalcSize:

Private Function CalcSize( _
 lngHeight As Long, _
 fToPoints As Boolean) As Long

 

Private Function CalcSize( _
 lngHeight As Long, _
 fToPoints As Boolean) As Single

9 (Added 1/31/2001)

577

Code fragments (also CalcSize in NonClient-
Metrics class)

points = -Int(lngHeight * 72 / lngLogPixelsY)

points = -Int(lngHeight * lngLogPixelsY) / 72

(Remove call to the Int function, because the code should return a Single.)

points = -(lngHeight * 72 / lngLogPixelsY)

points = -(lngHeight * lngLogPixelsY) / 72

12 (Added 8/20/2000)

765

Listing 12.31

If ((GetAttr(strPath & strFile) And lngAttr) >0) _

 And (strFile <> ".") And (strFile <> "..") Then

If (strFile <> ".") And (strFile <> "..") Then

Back to errata