Welcome Guest!
 VB.NET Helper
 Previous Message All Messages Next Message 
VB .NET Helper Newsletter  Rod Stephens
 Apr 17, 2009 15:15 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/
==========

    VB.NET Contents:
1. New HowTo: Make a form with a fixed-sized column between two other
columns that ahre the remaining available space in Visual Basic .NET
2. New HowTo: Compare the contents of two directories in Visual Basic
.NET
==========
++++++++++
<VB.NET>
++++++++++
==========
1. New HowTo: Make a form with a fixed-sized column between two other
columns that ahre the remaining available space in Visual Basic .NET
http://www.vb-helper.com/howto_net_same_size_columns.html
http://www.vb-helper.com/HowTo/howto_net_same_size_columns.zip

This example demonstrates a seldom-used control: TableLayoutPanel. Add a
TableLayoutPanel to the form and dock it to fill the form.

Select the control and click the SmartTag on its upper right corner. (It
looks like a little white square with a black triangle in it.) Use the
Add Column, Add Row, Remove Last Column, and Remove Last Row commands to
get the number of rows and columns you want. This example uses one row
and three columns.

If the SmartTag is closed, open it again and select the "Edit Rows and
Columns" command. Select the row or column you want to edit in the list
on the left. Then use the controls on the right to set the item's size.

For this example, set these values:

    Column    Size Type    Size Value
    ------    ---------    ----------
    Column1   Percent          50
    Column2   Absolute        100
    Column3   Percent          50

Now when the form resizes, the middle column remains 100 pixels wide and
the other columns share the remaining available space. Use Dock, Anchor,
and other properties to arrange the controls inside each of the
TableLayoutPanel's cells.
==========
2. New HowTo: Compare the contents of two directories in Visual Basic
.NET
http://www.vb-helper.com/howto_net_compare_directories.html
http://www.vb-helper.com/HowTo/howto_net_compare_directories.zip

When you fill in the names of two directories and click the Compare
button, the following code executes. It uses
My.Computer.FileSystem.GetFiles to get ReadOnlyCollections listing the
files in the two directories. The code then calls subroutine
SortCollection to sort the collections and turn them into arrays.

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.

' List the files in each directory.
Private Sub btnCompare_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCompare.Click
    ' Get sorted lists of files in the directories.
    Dim files1 As ReadOnlyCollection(Of String) = _
        My.Computer.FileSystem.GetFiles(txtDir1.Text)
    Dim file_names1() As String = SortCollection(files1)

    Dim files2 As ReadOnlyCollection(Of String) = _
        My.Computer.FileSystem.GetFiles(txtDir2.Text)
    Dim file_names2() As String = SortCollection(files2)

    ' Compare.
    Dim i1 As Integer = 0
    Dim i2 As Integer = 0
    Do While (i1 < file_names1.Length) AndAlso (i2 < file_names2.Length)
        If file_names1(i1) = file_names2(i2) Then
            ' They match.
            dgvFiles.Rows.Add(New Object() {file_names1(i1),
file_names2(i2)})
            i1 += 1
            i2 += 1
        ElseIf file_names1(i1) < file_names2(i2) Then
            ' Display the directory 1 file.
            dgvFiles.Rows.Add(New Object() {file_names1(i1), Nothing})
            i1 += 1
        ElseIf file_names1(i1) > file_names2(i2) Then
            ' Display the directory 2 file.
            dgvFiles.Rows.Add(New Object() {Nothing, file_names2(i2)})
            i2 += 1
        End If
    Loop

    ' Display remaining directory 1 files.
    For i As Integer = i1 To file_names1.Length - 1
        dgvFiles.Rows.Add(New Object() {file_names1(i), Nothing})
    Next i

    ' Display remaining directory 2 files.
    For i As Integer = i2 To file_names2.Length - 1
        dgvFiles.Rows.Add(New Object() {Nothing, file_names2(i)})
    Next i
End Sub

Subroutine SortCollection takes a ReadOnlyCollection(Of String) as a
parameter. It builds an array and copies the collection's values into
it. It then calls the Quicksort subroutine to sort the array and returns
the result.


' Build an array holding the sorted values in
' the ReadOnlyCollection(Of String).
Public Function SortCollection(ByVal coll As ReadOnlyCollection(Of
String)) As String()
    ' Move the items into an array.
    Dim result(coll.Count - 1) As String
    For i As Integer = 0 To coll.Count - 1
        ' Get just the file title.
        Dim file_info As New FileInfo(coll(i))
        result(i) = file_info.Name
    Next i

    ' Sort the array.
    Quicksort(result, 0, coll.Count - 1)

    ' return the result.
    Return result
End Function

Download the example to see how the Quicksort subroutine works or look
at this Web page: http://www.vb-helper.com/howto_quicksort.html.
==========
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.