Q: Why did the Irishman wear two condoms?
A: To be sure, to be sure.
(Apologies to any Irish who happen to be reading this.)
I’m currently working on a project where I need to upgrade an application to support some new functionality. This application was originally written by others,
While I was doing a review of the code, I found a segment like this (names anonymised):
CountOfIDs = ds.Tables(“SomeTable”).Rows.Count Select Case CountOfIDs Case 0 ‘ Do Nothing Case Is >= 1 If CountOfIDs >= 1 Then ‘ Do Something End If End Select
Those IDs are slippery little things - better check twice, to be sure.
(Hint for the C#/C++/etc readers: VB doesn’t need a ‘break’ statement to exit a select/switch block)

2 Comments
Break statements are nice in some cases when you want the code to follow into the next statement.
ie
switch (message)
{
case ‘notErr’: ; break;
case ‘err1′:
case ‘err2′:
case ‘err3′: MessageBox.Show(”An error occured!”+message);
break;
}
May 16th, 2007 at 3:41 pm. Permalink.
I know, there’s plenty of other very handy uses for them too
May 16th, 2007 at 4:56 pm. Permalink.