Archive for the ‘Uncategorized’ Category

Simple textbox validation

May 10, 2010 Leave a comment

The thing that i really get out of this is the UpdateSourceTrigger – i always forget that bit.

For this example, pretend you have a class which holds an integer. Go ahead and bind the textbox to that integer.

How do you validate that an integer is being typed in, as it is being typed?


<TextBox Height="23" Margin="94,0,64,93" Name="TextBox2" VerticalAlignment="Bottom">
<Binding Path="Age" UpdateSourceTrigger="PropertyChanged" >

Categories: Uncategorized

Email validation (regex + VB.NET)

May 3, 2010 Leave a comment

Private Shared Function IsValidEmailAddress(ByVal email As String) As Boolean


‘ This regex pattern came from:

Dim pattern As String = “^(?!\.)(“”([^””\r\\]|\\[“”\r\\])*””|([-a-z0-9!#$%&’*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$” 

Return Regex.IsMatch(email, pattern, RegexOptions.IgnoreCase)

 End Function

Categories: Uncategorized

Google Search Suggestions

December 11, 2009 Leave a comment

I was able to get a Google-like search suggestions box happening in almost no time with help from I’ve found this one to be REALLY handy.

Categories: Uncategorized

Excel Sheets being ‘Half’ Active

November 1, 2009 Leave a comment

I encountered a very interesting bug this week. The initial symptom was:

When any values in a SQL Server 2005 stored procedure result that I’m using in an Add-In are of type DATETIME or SMALLDATETIME then the corresponding cells (i.e. same sheet address) in the previously active worksheet (?!) are formatted to DATETIME, even when the data in those cells is formatted in Excel as Number or Currency.

CopyFromRecordset was being used to populate the currently active worksheet.

The answer ended up coming from harfang on

Even though the following SHOULD give you a reference to a newly added, active worksheet:

‘Put results to new sheet

Dim NewSheet As Worksheet


Set NewSheet = ActiveSheet

it only ‘half’ recognizes the new sheet as active. The implication being that NewSheet.CopyRecordset DOES copy values into the new sheet, but the formatting subroutines somehow link to the previously active sheet. More annoyingly, this only occurs for DATETIME field types, because any currency or numeric formatting wasn’t applied to the previously active sheet. This can be solved by adding one line:


which ‘fully’ registers NewSheet as active.

How frustrating! I’d be interested to see any Microsoft articles documenting this.

For more code samples and details on the solution check:


P.S. I’d love to get comments on good / free screencasting / screen recording software. This bug was on the more tricky side to explain and a short video showing symptoms would be really helpful.

Categories: Uncategorized

Very cool graphing techniques

September 7, 2009 1 comment

Thanks to Hans Rosling and his TED Talk for a cool example of scatter graphs.

Sure, the talk was interesting (I never thought of the ‘developing world’ paradigm as outdated) but, more impotantly to this blog, the coolest points for me of the Trendalyzer beta are:

  • Select a few dots out of dozens on the graph that will have a kind of ‘trail’ when animated over time.
  • Control the ratio of dot size in the bottom right (i.e. what are the min and max bounds for each dot?)


Categories: Uncategorized