Home

Press Releases and News

Bookstore

Software

Support

Ordering Information

Links

About VB2Java.COM

Articles:

Visual Basic Articles

VB 2 Java Articles

Java Articles

Misc. Articles

Updated on:
Thursday, Feb 7, 2002

Visual Basic Annotated Archive Updates

Visual Basic Annotated Archives
David Jung and Jeff Kent

Unique in its focus on advanced programming concepts, Visual Basic Annotated Archives explains how to extend and transcend the built-in limitations of Visual Basic using the Win32 API and subclassing. It also provides extensive coverage of cutting-edge programming techniques for using ADO 2.0, Dynamic HTML, Web Classes, and the Microsoft Transaction Server. All aspects of application development, including the user interface, business objects, COM objects, and programming for the Internet are thoroughly covered. The book's code components are ready-to-use for development of high-performance applications for the Internet, intranet, and client/server environments. The detailed expert annotations will enable you to customize code components to fit your needs. A valuable CD-ROM containing all of the book's source code and applications is also included. Visual Basic Annotated Archives is a unique and dynamic resource you'll use time and time again.


Chapter 11 Correction - XCopy32

The code highlighted in blue is what's different. We forgot to use the AND operator to perform a bitwise comparison of the value returned from the GetAttr function and the file attribute we were looking for. A bitwise comparison is a bit-by-bit comparison between identically positioned bits in two numeric expressions.

Public Function XCopy32(SrcDrv As String, SrcDIR As String, _
    DestDrv As String, DestDIR As String, _
    Optional bInc_SubDir As Boolean) As Boolean

    Dim Result As String
    Dim rc As Boolean
    Dim nDirCount As Integer
    Dim nFileCount As Integer
    Dim x As Integer
    Dim z As Integer
    Dim DIRList() As String
    Dim FileList() As String

    nDirCount = 0
    nFileCount = 0

    XCopy32 = False

    On Error Resume Next

    ChDrive SrcDrv

    If Not Err = 0 Then Exit Function

    ChDir (SrcDrv & "\" & SrcDIR)

    If Not Err = 0 Then Exit Function

    ChDrive DestDrv

    If Not Err = 0 Then Exit Function

    ChDir (DestDrv & "\" & DestDIR)

    If Not Err = 0 Then
        Err = 0
        MkDir (DestDrv & "\" & DestDIR)
        If Not Err = 0 Then Exit Function
    End If
    On Error GoTo 0
    Result = Dir((SrcDrv & "\" & SrcDIR & "\*.*"), vbDirectory)
    Do
        If (Result = "." Or Result = "..") = False Then
            Exit Do
        Else
            Result = Dir()
        End If
    Loop
    Do
        If Result = "" Then Exit Do
        If (GetAttr(SrcDrv & "\" & SrcDIR & "\" & Result) And vbDirectory) = _
            vbDirectory Then
            nDirCount = nDirCount + 1
            ReDim Preserve DIRList(nDirCount)
            DIRList(nDirCount) = Result
        Else
            nFileCount = nFileCount + 1
            ReDim Preserve FileList(nFileCount)
            FileList(nFileCount) = Result
        End If
        Result = Dir()
    Loop
    If bInc_SubDir = True Then
        For x = 1 To nDirCount
            rc = XCopy32(SrcDrv, (SrcDIR & "\" & DIRList(x)), _
                DestDrv, (DestDIR & "\" & DIRList(x)), True)
            If rc = False Then Exit Function
        Next
    End If
    For z = 1 To nFileCount
        FileCopy (SrcDrv & "\" & SrcDIR & "\" & FileList(z)), _
            (DestDrv & "\" & DestDIR & "\" & FileList(z))
    Next
    XCopy32 = True

End Function
Outlook 2000 Programming Bible