|
VB Helper Newsletter
|
Rod Stephens
|
Jan 23, 2009 15:17 PST
|
Lots of miscellaneous stuff this week.
----------
Even if you have time for nothing else, everyone should look at the
item:
Win32/Conficker.B/Downadup
----------
If you use Visual Basic 6, be sure to take the survey mentioned in the
Visual Basic 6 version of this newsletter
(http://ecustomeropinions.com/survey/survey.php?sid=459561756).
----------
Someone posted a second review of my database book, "Beginning Database
Design Solutions."
You can read it at
http://www.amazon.com/exec/obidos/ASIN/0470385499/vbhelper.
(Still no reviews at Amazon.co.uk.)
----------
Did you know...
That you can find a list of (almost) everything posted to the VB
Helper Web site in chronological order at:
http://www.vb-helper.com/index_all.html
Don't go there unless you have a high-bandwidth connection, though,
because it's HUGE.
----------
Thanks for subscribing!
Rod
RodSte-@vb-helper.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. Microsoft Survey: Visual Basic 6 Usage
VB.NET Contents:
2. New Tip: Downgrade Visual Basic 2008 projects to Visual Basic 2005
3. Updated HowTo: Make a ListView control sort using the column you
click in VB .NET
Both Contents:
4. New DevX Article, WPF Wonders: Getting Started with WPF
5. New DevX Article, WPF Wonders: Properties and Events
6. Win32/Conficker.B/Downadup infections
7. Updated Links
8. New Links
9. Updated Book: Visual Basic 2008 Programmer's Reference
==========
++++++++++
<VB6>
++++++++++
==========
1. Microsoft Survey: Visual Basic 6 Usage
http://ecustomeropinions.com/survey/survey.php?sid=459561756
This is a short survey that should only take 5 minutes or so. It
basically asks whether you are supporting Visual Basic 6 applications
and when you plan to upgrade them to .NET (if ever).
It's likely that the survey results will tell Microsoft how much to
support Visual Basic 6 so if you want support, here's your chance to
tell them.
If you take the survey before 11:59pm on 26th January 2009, you may win
one of four free places in a 4-day Visual Basic 2008 training worth
£1,640.
==========
++++++++++
<VB.NET>
++++++++++
==========
2. New Tip: Downgrade Visual Basic 2008 projects to Visual Basic 2005
http://www.vb-helper.com/tip_downgrade_vb2008.html
Thanks to Ariel Canievsky for sending this in. Ariel says:
Do you remember the old VB6toVB5 downgrader tool posted at your
page? I was a frequent-user of it, until I buy VB6.
Nowadays I've been facing a similar problem. I'm working on a
project in VS2008, and the mid-client needs a VS2005 version since they
(still) don't work with VS2008. So, this post saved my life:
Downgrade a VS 2008 .sln or .csproj to VS 2005.
http://saftsack.fs.uni-bayreuth.de/~dun3/archives/downgrade-vs-2008-sln-or-csproj-to-vs-2005-project-solution/139.html
Ariel also found a downgrader utility at
http://mises.org/Community/blogs/misestech/archive/2008/02/28/visual-studio-2008-to-2005-downgrade-utility.aspx.
==========
3. Updated HowTo: Make a ListView control sort using the column you
click in VB .NET
http://www.vb-helper.com/howto_net_listview_sort_clicked_column.html
http://www.vb-helper.com/HowTo/howto_net_listview_sort_clicked_column.zip
Thanks to Joe Mestrovich for adding support for date columns. (For
example, as strings "10/10/2000" comes before "1/1/1999" but as dates
10/10/2000 comes after 1/1/1999. Also as strings "01/20/2009" comes
before "1/1/2009" but as dates 01/20/2009 comes after 1/1/2009.)
-----
You can make the ListView sort by setting its Sorting property to
Ascending or Descending. However, the control only sorts on its items
not their sub-items. It won't even use the sub-items to brak ties when
the items have the same text.
To modify the control's sorting behavior, you must create a class that
implements the IComparer interface. The key to this class is the Compare
function. This function takes as parameters two ListView items to
compare. It should return -1 if the first should come before the second
in the sort order, 0 if the items are equal, and 1 if the first should
come after the second.
The ListViewComparer class has two private variables. The m_ColumnNumber
variable that gives the column that the object will use for sorting.
Variable m_SortOrder determines whether the control sorts ascending or
descending. These values are set by the class's constructor.
The Compare function compares the appropriate sub-items in the two
ListView items to determine how the two items should be ordered. It
needs to do a little checking to guard against the case when either of
the items doesn't have the sub-item that the object is trying to
compare.
Thanks to Kevin G for the improved comparison code that tests numeric
values as numbers rather than strings. (For example, as strings "9"
comes after "100" but as numbers 9 comes before 100.)
-----
' Implements a comparer for ListView columns.
Class ListViewComparer
Implements IComparer
Private m_ColumnNumber As Integer
Private m_SortOrder As SortOrder
Public Sub New(ByVal column_number As Integer, ByVal _
sort_order As SortOrder)
m_ColumnNumber = column_number
m_SortOrder = sort_order
End Sub
' Compare the items in the appropriate column
' for objects x and y.
Public Function Compare(ByVal x As Object, ByVal y As _
Object) As Integer Implements _
System.Collections.IComparer.Compare
Dim item_x As ListViewItem = DirectCast(x, _
ListViewItem)
Dim item_y As ListViewItem = DirectCast(y, _
ListViewItem)
' Get the sub-item values.
Dim string_x As String
If item_x.SubItems.Count <= m_ColumnNumber Then
string_x = ""
Else
string_x = item_x.SubItems(m_ColumnNumber).Text
End If
Dim string_y As String
If item_y.SubItems.Count <= m_ColumnNumber Then
string_y = ""
Else
string_y = item_y.SubItems(m_ColumnNumber).Text
End If
' Compare them.
If m_SortOrder = SortOrder.Ascending Then
If IsNumeric(string_x) And IsNumeric(string_y) _
Then
Return Val(string_x).CompareTo(Val(string_y))
ElseIf IsDate(string_x) And IsDate(string_y) _
Then
Return
DateTime.Parse(string_x).CompareTo(DateTime.Parse(string_y))
Else
Return String.Compare(string_x, string_y)
End If
Else
If IsNumeric(string_x) And IsNumeric(string_y) _
Then
Return Val(string_y).CompareTo(Val(string_x))
ElseIf IsDate(string_x) And IsDate(string_y) _
Then
Return
DateTime.Parse(string_y).CompareTo(DateTime.Parse(string_x))
Else
Return String.Compare(string_y, string_x)
End If
End If
End Function
End Class
The example program uses the following code to sort its ListView control
data. Variable m_SortingColumn keeps track of the column that the
program is currently sorting.
When the user clicks a column header, the program figures out which
column was clicked. It then determines the new sorting order it should
use. If the new column is the same as the old one, the program switches
the sort order. Otherwise it sorts ascending.
The program adds "> " to the column header when it sorts ascending and
it adds "< " when it sorts descending. It uses these characters to
determine the current sort order.
After it decides on the new sort order, the program removes the sorting
indicator ("> " or "< ") from the current sort column and adds it to the
new sort column.
Finally, the program creates a new ListViewItemSorter object, passing
its constructor the appropriate column number and sort order. It then
calls the ListView control's Sort method to make it resort its data.
' The column currently used for sorting.
Private m_SortingColumn As ColumnHeader
' Sort using the clicked column.
Private Sub lvwBooks_ColumnClick(ByVal sender As _
System.Object, ByVal e As _
System.Windows.Forms.ColumnClickEventArgs) Handles _
lvwBooks.ColumnClick
' Get the new sorting column.
Dim new_sorting_column As ColumnHeader = _
lvwBooks.Columns(e.Column)
' Figure out the new sorting order.
Dim sort_order As System.Windows.Forms.SortOrder
If m_SortingColumn Is Nothing Then
' New column. Sort ascending.
sort_order = SortOrder.Ascending
Else
' See if this is the same column.
If new_sorting_column.Equals(m_SortingColumn) Then
' Same column. Switch the sort order.
If m_SortingColumn.Text.StartsWith("> ") Then
sort_order = SortOrder.Descending
Else
sort_order = SortOrder.Ascending
End If
Else
' New column. Sort ascending.
sort_order = SortOrder.Ascending
End If
' Remove the old sort indicator.
m_SortingColumn.Text = _
m_SortingColumn.Text.Substring(2)
End If
' Display the new sort order.
m_SortingColumn = new_sorting_column
If sort_order = SortOrder.Ascending Then
m_SortingColumn.Text = "> " & m_SortingColumn.Text
Else
m_SortingColumn.Text = "< " & m_SortingColumn.Text
End If
' Create a comparer.
lvwBooks.ListViewItemSorter = New _
ListViewComparer(e.Column, sort_order)
' Sort.
lvwBooks.Sort()
End Sub
==========
++++++++++
<Both>
++++++++++
==========
4. New DevX Article, WPF Wonders: Getting Started with WPF
http://www.devx.com/dotnet/Article/40536
January 9, 2009
Learn how to use Windows Presentation Foundation to build engaging,
dynamic user interfaces that can really grab the user's attention.
This article proivides an overview of WPF and describes some of its
goals and capabilities. It illustrates those capabilities with lots of
pictures.
==========
5. New DevX Article, WPF Wonders: Properties and Events
http://www.devx.com/dotnet/Article/40650
January 22, 2009
Setting properties and handling events in Windows Presentation
Foundation are fundamentally different than they were in Windows Forms.
Find out how to deal with properties and events in both XAML and
WPF-targeted code.
==========
6. Win32/Conficker.B/Downadup infections
The Microsoft MVP program office sent this out to MVPs, asking that we
share it. Here's what they sent me:
PLEASE share this one with the Public
Actions Requested:
Please offer these links and resources to members of your community
to help mitigate this threat.
MS08-067
http://www.microsoft.com/technet/security/bulletin/ms08-067.mspx
Malicious Software Removal tool
http://www.microsoft.com/security/malwareremove/default.mspx
History: Win32/Conficker.B
http://www.microsoft.com/security/portal/Entry.aspx?Name=Worm:Win32/Conficker.B
-----
Based on feedback from MVPs and other sources, we are concerned
about the rise in reported infections due to the worm Win32/Conficker.B
also known as “Downadup.” Though systems which have already applied the
out-of-band released MS08-067 in October 2008 are protected, unpatched
system user have experienced system lockout and other problems.
Last week, we released a version of the Malicious Software Removal
tool (MSRT) that can help remove variants of Win32/Conficker and other
resources. Please share this information in your communities to help
address this threat.
-----
Background
Win32/Conficker.B exploits a vulnerability in the Windows Server
service (SVCHOST.EXE) for Windows 2000, Windows XP, Windows Vista,
Windows Server 2003, and Windows 2008. While Microsoft addressed this
issue in October with Microsoft Security Bulletin MS08-067, and
Forefront antivirus and OneCare (as well as other vendor’s anit-virus
products) helped protect against infections, many systems that have not
been patched manually through Server Update Services and
Microsoft/Windows Update or through Automatic Updates have recently come
under attack by this worm. Attacked systems may lock out users, disable
our update services and block access to security-related Web sites:
In response to this threat, Microsoft has:
- Updated the January version of the MSFT to detect and remove
variants of Win32/Conficker.B. You can download this version from the
MSRT from either the Microsoft Update site or through its associated
Knowledge Base article.
- Created the KB article 962007 “Virus alert about the
Win32/Conficker.B worm” to provide public details on the symptoms and
removal methods available to address this issue.
- Announced the release of the items and the virus threat itself
on the Microsoft Malware Protection Center blog.
It is our hope that these resources can assist you in resolving
issues with un-patched, infected systems and that you can apply MS08-067
to any other un-patched systems as soon as possible to avoid this
threat.
==========
7. Updated Links
http://www.vb-helper.com/links.html
HTML Help Generator
http://www.helpgenerator.com
Add-in geneators that generates HTML help files.
==========
8. New Links
http://www.vb-helper.com/links.html
4Tops
http://www.4tops.com
Addins for Microsoft Access and Excel. Importing Excel files in MS
Access, Creating documents from your Access database (Word, Excel, PDF,
email) and more.
==========
9. Updated Book: Visual Basic 2008 Programmer's Reference
http://www.vb-helper.com/vb_prog_ref.htm
Page 198
Paul Moss noticed a typo. In the XAML code's RowDefinition elements, the
Width property should be Height. (Rows have heights while columns have
widths.)
==========
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
|
|
 |
|