Article: Delegates and Business Objects - VB.NET Version
Some time ago I wrote an article for the CodeProject entitled “Delegates and Business Objects“. While the article was mostly about data binding and validation fundamentals, I also included a number of C# classes that made validation very easy.
A number of people have asked if I could provide a Visual Basic .NET version of the library. So, without further adue, I’ve uploaded a version of my PaulStovell.Common framework, which includes these classes in both a C# version and a VB.NET version. You can find the code on ProjectDistributor here:
http://projectdistributor.net/Projects/Project.aspx?projectId=240
Note that since anonymous delegates aren’t supported in Visual Basic .NET 2005, you need to declare one function per “rule”. This really isn’t as bad as it seems in practice, although it’s not as easy as the C# version using anonymous delegates.
I also took the opportunity to add a number of optimisations to the base DomainObject class, so it can validate and retrieve errors faster than ever.
I’m using these classes in Trial Balance, and I’m very happy with their stability. That said, the standard developer disclaimer applies: “It works on my machine!”

Why did you kibosh the Consultant Risks and Tips post?
Hi Paul,
Thanks for the great article and the VB.NET version of the code. I had to make the following revisions to the code to get it to work for me:
1) Property [Error] in DomainObject class:
a. “And” comparison operator should be “AndAlso”.
b. “” comparison operator should be “=”.
2) Property IsValid in DomainObject class: “IsNot” comparison operator should be “Is”.
3) Added “OnPropertyChanged(New PropertyChangedEventArgs(”IsValid”))” to end of NotifyChanged
subroutine in DomainObject class.
I can get a “Save” button to enable/disable when I have the properties of an object bound to text boxes, but I am struggling to get the same behavior when I have a list of business objects bound to a DataGridView. The data validation is working beautifully, I just cannot figure out how to get the Save button to disable when an object in the list has invalid data. Your feedback would be greatly appreciated!