The problem that i have is that there are several hundred cases, and it is in a loop, so it is taking a real long time.. Is there a VB.Net statement or construct that can search through a list of cases and return a function pointer? Or some other method that would be faster?

All it does is produce the code for a 1000 select case statement and code to loop through it looking for each value. Although the values are derived from numbers they are expressed as strings to make it similar to your situation.

If you run that and then select all, copy and paste the text from the file it produces into a sub and run that sub I doubt that you will find it "taking a real long time". Different systems will produce different results but, on mine, the result in the message box at the end was 2 seconds.

So my guess is that, if you want to reduce the time, you should be looking at the functions which your SELECT CASE routine is directing program flow to rather than at the SELECT CASE statement itself.

"Tremendous increase in speed". That's interesting. I've just run comparative tests, using a similar approach to that outlined above. That is, I wrote code to create 1000 instances of delegate functions and fill a hashtable with their addresses. I then copied that code into a form and iterated through a 1000 loop to call each function once. Here's the results.

I must stress that I'm not arguing with Fernando's answer, or the award of points to him. What matters is what works.

But I can't help wondering why. It's just that, so far as I know, a SELECT CASE statement in fact works with, in the background, its own hashtable so I would have been surprised if, of itself, the upfront hashtable approach was any quicker. My tests show that it isn't. For all practical purposes it is the same. So why, in the setting in this question, has it produced a "tremendous increase in speed"?

In relative terms the two methods are still, for all practical purposes, the same - although the slight edge that Select Case had before Delegate has now. But the most interesting thing is that the 2003 version is quite a bit faster than the 2005 version. There's progress for you!

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way.
I've always enjoyed working with graphics, but it's never too clever to re-invent …

In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB.
How Percona can help
Percona can help you determine if Percona Server for MongoDB is the right solution for …

In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB.
To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…