Monday, October 22, 2007

Nifty Microsoft utility fixed my IntelliPoint 6.2 upgrade woes

IntelliPoint is Microsoft's mouse companion software, which adds a number of handy features and functions to just about their entire mouse product line. 

I have always liked Microsoft's mice the best, so I always try to keep up with the latest version of IntelliPoint.

My current favorite mouse is the Wireless Laser Mouse 8000, which connects via a small bluetooth dongle, is as smooth as glass, and is fantastically accurate.  The only grudge I have is the location of the "forward" button (which is not even set to "forward" by default) — it was moved to the right side of the mouse, rather than staying under my thumb together with the "Back" button.

Microsoft recently upgraded IntelliPoint to version 6.2.  When I went to install it, it would almost finish, and then I'd get a nasty error box, which naturally was completely unhelpful, telling me that the problem could be disk space or "some other problem".  Nice.

I even tried uninstalling the old 6.1 version, but it refused to uninstall.  Arg!

Googling, I found a utility called "Windows Installer CleanUp Utility".  Sometimes weird install bugs are caused by a new versions of Microsoft installer software, so I gave it a try.

I installed and ran the application, the selected the IntelliPoint 6.1 software and clicked "Remove".  A peek at Vista's "Programs and Features" Control Panel applet confirmed that the software was removed from the list of installed programs.  ("Programs and Features" is the same thing as XP's "Add or Remove Programs".)

Then I tried installing 6.2 again, and it worked fine and completed normally.

The nice thing about the Windows Installer CleanUp Utility is that it is a real program that is now on my PC, ready to use if another install gets screwed up.  Thus, I would definitely recommend it to others as an important toolbox item.

Just a word of caution though: it should really only be used after all other options have been exhausted, because it permanently removes software from the list of installed programs.

Here is a link to the utility info and download page:

<Sorry, link is no longer available>

Friday, October 12, 2007

Simulating VB.NET's lost String() function

Before VB.NET was around — back in the days it was just called "Visual Basic" — there was a function named String(), which was used to repeat a character sequence multiple times.

For example, String("Abc", 5) produced "AbcAbcAbcAbcAbc".

In VB.NET, the String() function was dropped, probably because the name conflicts with the construction of a new String value, as in Dim str As New String().

When they dropped it from the language, I would have thought that they would replace it with a new function — maybe something like StrClone().

Searching the web, the question seems to be asked quite often, "How can you do the equivalent of String() in VB.NET?"

Annoyingly, every time it is asked, someone invariably answers by saying they should use the StrDup() function, or New String("A", 5).  They completely disregard that the person wants to concatenate a multi-character string, not one character.

One person even suggested incorrectly that the String constructor could be used to do it — as in New String("Abc", 5) — which it can't.  That would produce a string of 5 "A" characters.

So here is an easy solution.

To create a string consisting of 10 copies of "Abc":

MyString = Replace(Space(10), " ", "Abc")

Or, if you want to use all .NET framework methods (instead of the Visual Basic library), use the following:

MyString = New String(" "c, 10).Replace(" ", "Abc")

Note: the "c" character after the space (" "c) means a literal character (Char) instead of a character string.  It is a tiny efficiency.

Yes, there are other ways of doing this, perhaps by manipulating character arrays.  This, however, is a simple, maintainable — and quick — way of doing it.

With this little trick, you can create your own StrClone() function as follows:

Function StrClone(ByVal Source As String, ByVal Count As Integer) As String
    Return Replace(Space(Count), " ", Source)
End Function

A nice simple function to complete anyone's String library!  Hopefully Microsoft will consider adding this convenience function back into the Visual Basic library.