Welcome Guest!
 VB 6 Helper
 Previous Message All Messages Next Message 
VB 6 Helper Newsletter  Rod Stephens
 Apr 17, 2009 15:14 PDT 

Special thanks to Steve Smerker for posting a review of my database book
on the Barnes and Noble Web site:

    
http://search.barnesandnoble.com/Beginning-Database-Design-Solutions/Rod-Stephens/e/9780470385494/?itm=1#TABS

----------
This week I've posted Visual Basic 6 and Visual Basic .NET versions of a
simple drawing program that lets you show or hide a grid and turn grid
snapping on and off. If you compare them, you'll see many of the biggest
differences between drawing in Visual Basic Classic and Visual Basic
.NET.
----------
Have a great week and thanks for subscribing!

Rod
RodSte-@vb-helper.com

Books To Keep: http://www.BooksToKeep.com
----------
*** Now Available ***

Beginning Database Design Solutions
http://www.amazon.com/exec/obidos/ASIN/0470385499/vbhelper/

Visual Basic 2008 Programmer's Reference
http://www.amazon.com/exec/obidos/ASIN/0470182628/vbhelper/
==========

    VB6 Contents:
1. New HowTo: Compare the contents of two directories in Visual Basic 6
==========
++++++++++
   <VB6>
++++++++++
==========
1. New HowTo: Compare the contents of two directories in Visual Basic 6
http://www.vb-helper.com/howto_compare_directories.html
http://www.vb-helper.com/HowTo/howto_compare_directories.zip

When you fill in the names of two directories and click the Compare
button, the following code executes. It uses the Dir function to get the
names of the files in each directory and stores them in arrays. (Note
that the file name in the TextBoxes should include anym wildcards. For
example, C:\whatever\dir1\*.*.)

The code then calls the Quicksort subroutine to sort the arrays.
Download the example to see how the Quicksort subroutine works or look
at <A HREF="http://www.vb-helper.com/howto_quicksort.html">this Web
page</A>.

Next the code loops through the arrays comparing their entries. If two
entries match, the code adds them both to the program's DataGridView
control. If the files don't match, the program adds the one that comes
alphabetically first to the DataGridView and increments its array's
counter.

When the code finishes with all of the files in one of the arrays, it
dumpes the remaining items into the DataGridView.

Private Sub cmdCompare_Click()
Dim file_names1() As String
Dim file_names2() As String
Dim num_file_names1 As Integer
Dim num_file_names2 As Integer
Dim file_name As String
Dim i1 As Integer
Dim i2 As Integer
Dim i As Integer

    ' Get the files in the first directory.
    file_name = Dir$(txtDir1.Text)
    num_file_names1 = 0
    Do While Len(file_name) > 0
        num_file_names1 = num_file_names1 + 1
        ReDim Preserve file_names1(1 To num_file_names1)
        file_names1(num_file_names1) = file_name

        file_name = Dir$()
    Loop

    ' Get the files in the second directory.
    file_name = Dir$(txtDir2.Text)
    num_file_names2 = 0
    Do While Len(file_name) > 0
        num_file_names2 = num_file_names2 + 1
        ReDim Preserve file_names2(1 To num_file_names2)
        file_names2(num_file_names2) = file_name

        file_name = Dir$()
    Loop

    ' Sort the lists of files.
    Quicksort file_names1, 1, num_file_names1
    Quicksort file_names2, 1, num_file_names2

    ' Compare.
    lvwFiles.ListItems.Clear
    i1 = 1
    i2 = 1
    Do While (i1 <= num_file_names1) And (i2 <= num_file_names2)
        If file_names1(i1) = file_names2(i2) Then
            ' They match.
            AddFiles file_names1(i1), file_names2(i2)
            i1 = i1 + 1
            i2 = i2 + 1
        ElseIf file_names1(i1) < file_names2(i2) Then
            ' Display the directory 1 file.
            AddFiles file_names1(i1), ""
            i1 = i1 + 1
        ElseIf file_names1(i1) > file_names2(i2) Then
            ' Display the directory 2 file.
            AddFiles "", file_names2(i2)
            i2 = i2 + 1
        End If
    Loop

    ' Display remaining directory 1 files.
    For i = i1 To num_file_names1
        AddFiles file_names1(i), ""
    Next i

    ' Display remaining directory 2 files.
    For i = i2 To num_file_names2
        AddFiles "", file_names2(i)
    Next i
End Sub
==========
Archives:
    http://www.topica.com/lists/VBHelper
    http://www.topica.com/lists/VB6Helper
    http://www.topica.com/lists/VBNetHelper

Post questions at:
    http://www.topica.com/lists/VBHelperQA
	
 Previous Message All Messages Next Message 
  Check It Out!

  Topica Channels
 Best of Topica
 Art & Design
 Books, Movies & TV
 Developers
 Food & Drink
 Health & Fitness
 Internet
 Music
 News & Information
 Personal Finance
 Personal Technology
 Small Business
 Software
 Sports
 Travel & Leisure
 Women & Family

  Start Your Own List!
Email lists are great for debating issues or publishing your views.
Start a List Today!

© 2001 Topica Inc. TFMB
Concerned about privacy? Topica is TrustE certified.
See our Privacy Policy.