March 1, 2010, 1:21 pm
I think that Google might have the Gmail phishing filter set just a tad too strong. I was in my Gmail account this morning and accidentally clicked on the very first message I got in the account, which is of course the introductory e-mail that describes how to switch your existing e-mail over to Gmail. Here is what I saw:

February 23, 2010, 10:43 pm
In converting some legacy VB6 code to VB.NET, I noticed that there was a lot of use of the Format function in the code to convert numbers to strings. This makes sense as Format was pretty much the only game in town in VB6.
However, in .NET, they introduced a handy-dandy .ToString() method that, on the surface, seems to do much the same thing as the Format function. I have been able to use them pretty much interchangeably with the desired results coming out every time.
I started to wonder which way was faster. Since I am a big proponent of empirical knowledge instead of just trying to get the theoretical story behind the two ways to do this, I rolled together this quick VB.NET console application:
Imports System.Text
Module Module1
Sub Main()
Dim i As Integer
Dim r As Random = New Random()
Dim t As Double
System.Console.WriteLine("10,000,000 Formats")
Dim sb1 As New stringbuilder
t = Timer
For i = 1 To 10000000
sb1.Append(Format(r.NextDouble * 100.0, "###0.00 "))
Next
System.Console.WriteLine("Seconds elapsed: " + (Timer - t).ToString("#######0.00"))
System.Console.WriteLine("Length of string builder: " + sb1.Length.ToString())
System.Console.WriteLine()
System.Console.WriteLine("10,000,000 ToStrings")
Dim sb2 As New StringBuilder
t = Timer
For i = 1 To 10000000
sb2.Append((r.NextDouble * 100.0).ToString("###0.00 "))
Next
System.Console.WriteLine("Seconds elapsed: " + (Timer - t).ToString("#######0.00"))
System.Console.WriteLine("Length of string builder: " + sb2.Length.ToString())
System.Console.WriteLine()
System.Console.WriteLine("Press any key to end the program ")
System.Console.ReadKey()
End Sub
End Module
And here are the results:

As you can see, the ToString method is about 15% faster when doing 10 million calls with random numbers.
Oh, and by the way, Happy Pancake Day.
February 12, 2010, 3:23 pm
A co-worker brought this link to my attention:
Silicon Valley’s Island of Misfit Tech
I can’t believe that, with all of the trips that I have made to the Bay Area, that I never heard of this place or stumbled upon it by accident. I so want to go there now to look for a copy of Microsoft Bob. Or maybe I should try to sell my copy of Microsoft Dogs.
January 28, 2010, 11:23 pm
It has apparently been a long time since I had to do any kind of reading and writing from the console in C.
I was trying to work through the Minesweeper problem on the UVa Online Judge site, and my submissions kept failing with a “Runtime error”, with no explanation given as to the source of the problem. Of course, everything was working swimmingly when I was trying to run through the code as a command line application in Xcode on my Mac. Some investigation into this led me to pad my arrays and strings so that there was no chance of an array index going into areas they were not supposed to, but it was still failing.
I finally discovered the problem was that I had used an int variable in my code, but a %i instead of a %d in the scanf format string. As soon as I switched that over, the “Runtime error” went away. And I was able to move on to the “What do you mean ‘Wrong answer’???” part of my evening.
Oh, and Happy Data Privacy Day everyone.
January 27, 2010, 1:56 pm
In converting my VB6 code over to VB.NET, I was looking for an easy way to take the different between two DateTime items and display in hours and minutes. The TimeSpan gives a nice structure to dive into the difference and see exactly the interval, but I was hoping to find a way to output this in the same way that you can use the ToShortTimeString method of DateTime.
As it turns out, I found a posting by Jay Barlow that mentions converting the time different to a date time, and then using a custom format string to do the work so that I wouldn’t have to. Here is my new VB.NET code, where rec is a class that includes the start and end date and duration is a string that holds the information to be displayed:
If rec.endDate IsNot Nothing Then
Dim ts As TimeSpan = CDate(rec.endDate).Subtract(rec.startDate)
Dim dt As DateTime = DateTime.MinValue.Add(ts)
duration = "Event duration: " + dt.ToString("H:mm")
End If
Oh, and one more thing. Am I the only one in the world that thinks that iPad is the worst product name in history? Sure, it is so close to iPod so as to create brand recognition and draw comparisons, but I would just wonder what kind of names were shot down, and if any of them did not begin with the letter i.
By the way, Happy (Belated) Australia Day.
January 18, 2010, 8:39 pm
I saw a news blurb a while back about this new app from the Google folks called My Tracks. I downloaded it to my Droid right away, but really didn’t try it out until today.
So I decided to try and use the application while walking one of my dogs. The navigation around the application is pretty simple, and the track recording seemed to work very well. After I got back from the walk, I was able to see the path that I walked along with a bunch of statistics about it.
The program has upload options to send to Google Docs and Google Maps, so I tried them both at first. This first upload did complete to my Google Docs, but I did have a bit of trouble when it tried to upload the track to Google Maps. The first few times I tried it, I got some miscellaneous errors, such as an authentication error and other nondescript messages. Finally it did go through, and the track then was showing up on the My Maps page of Google Maps.
Even though this app is in the early stages of development, I think it rates quite well. I would give it a 4 star rating, if only because I had some trouble getting the Google Maps upload working.
If you can find it in your heart to help out a fellow nerd, please help out Shawn Powers, he is having a tough go of it. Here are the details:
Urgent: Help Shawn Powers & Family
Oh, and I hope everyone out there had a good Martin Luther King Day.
January 8, 2010, 10:18 pm
The few dozen remaining WinForms developers left on this planet may have noticed that, for some reason, a group box with radio buttons in it as designed in the Visual Studio 2008 environment will have the first radio button of the first group box automatically selected when the form comes up, even though all of the radio buttons have their Checked property set to false in the design environment. It never used to do this in VB6, as when you ran the application, the group of radio buttons would have no members selected.
The problem manifests itself when you are trying to perform additional tasks in the CheckedChanged event of the radio buttons when the user selects one of the radio buttons, since the first radio button is being automatically selected.
I asked this question on Stack Overflow, and got a couple of replies. The one that I finally used to solve the problem was to set the Checked property of the radio buttons to false in the form’s Shown event, which I had never used before. By doing this, the first radio button was no longer automatically showing up checked.
One other thing that I had to do in addition was to cast the sender into a RadioButton and look at the Checked property of the clicked radio button in the CheckedChanged event, as that event is fired for radio buttons both being turned on and also turned off.
Oh, and happy National English Toffee Day!
January 1, 2010, 2:44 pm
I have always enjoyed alpine skiing ever since the first time that I went to the local ski area in Ohio. I don’t make it to Brandywine much any more because I have been skiing in the West many times over the years, and once you go there, it is hard to go back to the little ski bumps. (Even though I live closer to the Ohio bunny slopes now than I ever have.)
A few Christmases ago, my wife bought me a deck of playing cards called Ski USA, A Bird’s-Eye View of 52 of the Best Ski Mountains, with each of the 52 cards having a trail map and vital statistics for 52 different American ski resorts. In this new decade, I have made a resolution to try and make a go of visiting the rest of the 52 resorts depicted on the playing cards that I have not been to yet.
I put together a Google Earth KML file with the 52 resorts on it, if you want to use it to track your own progress.
Ski USA KML file (Google Earth)
BTW, if you are interested in buying the deck of cards, here is a link to it on Amazon’s web site:
Ski USA Playing Card Deck
I am thinking of heading to New England in the winter/early spring time frame, if anyone has any suggestions about which of the resorts to visit, please let me know.
Oh, and Happy New Year everyone!
December 28, 2009, 7:57 pm
One of the things that I really liked (and used quite a bit) in the VB6 IDE was the ability to use the design surface to create a form with a bunch of controls with the same name as a control array. You would create the controls on the design page, give it the same name as another control, and the Index property would automatically be incremented. This would then let me use a loop to manipulate and examine these controls.
This functionality is missing in VB.NET, as I discovered when I tried to do my first .NET Compact Framework application way back when Visual Studio 2003 was shiny and new, and has continued to be missing from the feature set in VS2005 and VS2008.
Microsoft is not much help on this front. Their solution is to create the forms in code, as described in this article:
Not so helpful link
But I like using the design surface to create forms. A co-worker suggested we try to do a test in C# and tamper with the designer.cs file to create an array of controls in there, which worked OK. The big problems there were that the controls showed up on the design surface, but they could not be clicked and modified. Also, when we added a control to the form and saved it, all of the customizations we made to the designer file disappeared. (Oops.)
So instead, what I am now doing is creating my forms in the designer as before, with each control of the set having a different name with a number after it (such as cboName0, cboName1, etc.), referring to the index of the control in the array. At the top of the form’s class I have the arrays defined:
Dim cboName(10) as ComboBox
Dim lblNumber(10) as Label
Then, in the form load event, I am calling this subroutine:
Sub SetUpControlArrays()
For Each cb In Me.Controls.OfType(Of ComboBox)()
If cb.Name.Contains("cboName") Then
cboName(CInt(cb.Name.Replace("cboName", ""))) = cb
End If
Next
For Each lbl In Me.Controls.OfType(Of Label)()
If lbl.Name.Contains("lblNumber") Then
lblNumber(CInt(lbl.Name.Replace("lblNumber", ""))) = lbl
End If
Next
End Sub
Now I have the ability to address the controls in the same way that I used to do in VB6. The fact that I lived with this missing feature for about 6 years and just now figuring out a decent way around the problem pretty much guarantees that VS2010 will put the control arrays back in.
EDIT: At the request of a Strong Bad fan who shall remain nameless, I changed up the code above to be a bit more friendly. The previous code only extracted the rightmost 1 character from the name of the control on the design surface, which would not work if you had a control name such as cboName10.
December 26, 2009, 2:34 pm
I finally got tired of living with the inability of WordPress to automatically update on this very blog site, which is hosted on 1&1, so I did some digging into the WordPress forums. In addition to the automatic update just hanging up when trying to download the updated zip file, I also would never see anything appear under the WordPress Development Blog and Other WordPress News sections on the right side of the main dashboard.
One of the solutions mentioned was to set up your web site to use PHP5 instead of PHP4. So, I logged into the 1&1 administration panel, but could find no setting for the version of PHP used by my web sites. (My company has sites hosted on Rackspace Cloud, formerly Mosso, which has a nice little choice list on their admin panel to set the PHP version.)
A quick phpinfo() page on my blog site indicated that version 4.x of PHP is used. An equally quick search of the 1&1 FAQs yielded the answer.
You have to put the following line into the .htaccess file in the root of your web site:
Apparently, this makes it appear to 1&1 hosting that all of your PHP files are meant to be run using PHP version 5 instead of version 4, without having to rename all of your files to have a php5 extension instead of php.
Oh, and I hope everyone is having a nice Boxing Day.