Click here to Skip to main content
15,914,419 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: It's the thought that counts Pin
Thomas Weller23-Mar-09 8:58
Thomas Weller23-Mar-09 8:58 
GeneralRe: It's the thought that counts Pin
CurtD24-Mar-09 8:12
CurtD24-Mar-09 8:12 
GeneralRe: It's the thought that counts Pin
Vikram A Punathambekar6-Apr-09 19:55
Vikram A Punathambekar6-Apr-09 19:55 
GeneralRe: It's the thought that counts Pin
BillW3323-Apr-09 6:47
professionalBillW3323-Apr-09 6:47 
GeneralRe: It's the thought that counts Pin
Megidolaon24-Mar-09 2:11
Megidolaon24-Mar-09 2:11 
GeneralVB Select Case statement incarnation of C# if (true = [condition]) Pin
David St. Hilaire14-Mar-09 6:36
David St. Hilaire14-Mar-09 6:36 
GeneralRe: VB Select Case statement incarnation of C# if (true = [condition]) Pin
Lutosław14-Mar-09 7:42
Lutosław14-Mar-09 7:42 
GeneralRe: VB Select Case statement incarnation of C# if (true = [condition]) Pin
David St. Hilaire14-Mar-09 10:34
David St. Hilaire14-Mar-09 10:34 
Why? Normally the test expression is evaluated at runtime, and the result is compared to each case until a match is found. In my experience, the case expressions are usually constant, and they are usually unique values (in C# & C++ these behaviors are enforced).

Here, the test expression is the constant, and the case expressions are calculated at runtime. And, since in the actual example there were several expressions that were returning boolean results, there were several cases that would have the same values.

That is what I mean by backward. It certainly works, and maybe it just struck me as odd because my background is predominantly C++ & C#. But, the company I'm at has a large body of VB.NET code and this is the only instance I've seen of a case statement done this way. And, it is backward compared to the example in MSDN as well.

It seems like if you want to evaluate a series of expressions until you find one that is true, using an if-then-elseif would be more appropriate. Just my opinion.
GeneralRe: VB Select Case statement incarnation of C# if (true = [condition]) Pin
Lutosław14-Mar-09 15:08
Lutosław14-Mar-09 15:08 
GeneralRe: VB Select Case statement incarnation of C# if (true = [condition]) Pin
supercat916-Mar-09 7:20
supercat916-Mar-09 7:20 
GeneralRe: VB Select Case statement incarnation of C# if (true = [condition]) Pin
Mark Hurd16-Mar-09 15:14
Mark Hurd16-Mar-09 15:14 
RantThe Horror... [modified] Pin
Megidolaon13-Mar-09 1:42
Megidolaon13-Mar-09 1:42 
GeneralRe: The Horror... Pin
PIEBALDconsult13-Mar-09 6:29
mvePIEBALDconsult13-Mar-09 6:29 
GeneralRe: The Horror... Pin
Lutosław13-Mar-09 11:04
Lutosław13-Mar-09 11:04 
GeneralRe: The Horror... Pin
Megidolaon16-Mar-09 0:52
Megidolaon16-Mar-09 0:52 
GeneralRe: The Horror... Pin
Lutosław13-Mar-09 11:23
Lutosław13-Mar-09 11:23 
GeneralRe: The Horror... Pin
Megidolaon16-Mar-09 0:54
Megidolaon16-Mar-09 0:54 
GeneralRe: The Horror... Pin
Robert Surtees14-Mar-09 10:54
Robert Surtees14-Mar-09 10:54 
GeneralRe: The Horror... Pin
Megidolaon16-Mar-09 0:55
Megidolaon16-Mar-09 0:55 
GeneralRe: The Horror... Pin
killabyte14-Mar-09 21:53
killabyte14-Mar-09 21:53 
GeneralRe: The Horror... Pin
PIEBALDconsult20-Mar-09 18:27
mvePIEBALDconsult20-Mar-09 18:27 
GeneralRe: The Horror... Pin
Member 368078519-Mar-09 6:44
Member 368078519-Mar-09 6:44 
GeneralRe: The Horror... Pin
johnsyd8-Apr-09 21:16
johnsyd8-Apr-09 21:16 
GeneralWTF Name Field [modified*2] Pin
Brady Kelly7-Mar-09 2:47
Brady Kelly7-Mar-09 2:47 
GeneralRe: WTF Name Field [modified*2] Pin
ZaoWuYa9-Mar-09 20:44
ZaoWuYa9-Mar-09 20:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.