Variables

  • Thread starter Thread starter Bernard Bourée
  • Start date Start date
B

Bernard Bourée

I'm coding a complex system which require thousands of varaibles.
I would like to create most of them dynamicly with a template.

for exemple I woould like to be able to declare my varaibles as follows

Dim s1, s2 as string
Dim s1 & s2 as Decimal

Of course it does not work.

Is there a working arround ?
 
Bernard Bourée said:
I'm coding a complex system which require thousands of varaibles.
I would like to create most of them dynamicly with a template.

for exemple I woould like to be able to declare my varaibles as follows

Dim s1, s2 as string
Dim s1 & s2 as Decimal

Of course it does not work.

Is there a working arround ?

You can use arrays and collections like System.Collections.Hashtable to
provide storage containers for arbitrary data elements.

eg

Dim values As New System.Collections.Hashtable
values.Add("A", 2)
values.Add("B", 3)
Console.WriteLine(values("A"))

David
 
Bernard Bourée said:
I'm coding a complex system which require thousands of varaibles.
I would like to create most of them dynamicly with a template.

for exemple I woould like to be able to declare my varaibles as follows

Dim s1, s2 as string
Dim s1 & s2 as Decimal

Of course it does not work.

Is there a working arround ?


Take a look at arrays and collections ('ArrayList', 'Hashtable', ...).
 
Bernard,

The first approach for this is in my opinon an array.
Is it a fixex array than just a fixex array by instance
dim s(999) as string 'Because of a strange fact of VisualBasic are this 1000
strings.

When it is dynamic you can use an arraylist
dim s as new arraylist

In the first case you fill the data with
s(0) = "Whatever"

In the second case you fill the data with
s.add("Whatever")

However see my message in your other question what is posible a better
approach.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top