i want to declare some variables in my program, but i dont know how many to declare, this is why i need to declare them dinamically.including declaring a different name for them.
how do i do this?
Printable View
i want to declare some variables in my program, but i dont know how many to declare, this is why i need to declare them dinamically.including declaring a different name for them.
how do i do this?
As a start you can just declare a "dynamic" array in VB like that :
dim DynArray() as string
and each time you want to add an element to that array , you do it this way :
Redim Preserve DynArray (x)
DynArray(x-1) = "Hello" & x
as for declaring variables with new names at runtime ...
I dont know if it is doable in VB ... Not directly anyway ... I rather not say something of which I am not sure ...
Hope that helped
can you not use a dynamic array?
Regards
Chris.
Yes .. depends on your purpose .. but in this case why wouldnt you want to use a dynamic array????
my biggest problem is naming the variables
That shouldn't be a problem, unless they appear to be reserved keywords and functions. You could use prefixes like a, or ad for array or array dynamic, or so, but i wouldn't. Name your variables after their purpose.