Create a dynamic varable in VB

Chris Jones
Chris Jones used Ask the Experts™
on
Hello,

i need help dynamicly creating varables based on database  entry and use the varables throught my program. These varables will have values assosiated with them in the database


FOR EXAMPLE

test1 , string,, "helo world"
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Define a static type with static fields as your variables and modify the variables where and when required:-

public static class MyData
{
public static string variable1;
public static string variable2;
}

MyData.variable1="test";
MyData.variable2="Hello";

Open in new window

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

Commented:
Use a Dictionary with the variable name as the key:
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
Hi,

You can use the Generic classes of namevaluecollection
for ex.

 Private NameCollection As NameValueCollection = New NameValueCollection()

use this collection to add the key and values those are come from database

NameCollection.add(keyname,value);
Chris JonesLead Application Web Developer

Author

Commented:
Thanks the generic worked for me

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial