views:

50

answers:

1

This hopefully is a simple question with a simple answer. If I have a list box or something that has a list of like 4 years (like 2006 through 2009), how do I programmatically make variables of these years with names like pTable2006, pTable2007, etc (as ITable of course).

If this isn't possible and I have publicly declared these tables in the declarations (like pTable2006 as ITable, pTable2007 as ITable, etc), how can I programmatically assign these variables based on user choice? What I'm asking is, if the user wants to choose years 2006 and 2007, how can I write this: pTable & ListBox.Items.Item(0) = [table path string] & ListBox.Items.Item(0) (please ignore the syntax of the "listbox", I'm just trying to come up with an example)

I hope that makes sense. I'm not sure the best way to ask that, but whenever I put something like pTable & "string", I get an error.

Thanks, Adrian

+2  A: 

I'd consider using a generic dictionary of ITable where "2005" would be the key. http://adventuresdotnet.blogspot.com/2007/10/vbnet-generic-dictionaries.html

Kirk Kuykendall
+1: it's very useful to learn how to use data structures besides arrays and lists.
cfern
Thanks Kirk. I'll have a look at these blog posts. It seems quite complicated to me (so far) but hopefully I'll be able to figure it out. I was hoping this could be done in VBA AND VB.NET but it looks like this is not a VBA thing.
Adrian