Hi
Can anyone tell me if/how it's possible to declare a variable whose name is the value of another variable ?
e.g.
Var1 = "CC203" then
"Dim Var1" - which would dim a variable of name CC203
Cheers
GavinB.
Printable View
Hi
Can anyone tell me if/how it's possible to declare a variable whose name is the value of another variable ?
e.g.
Var1 = "CC203" then
"Dim Var1" - which would dim a variable of name CC203
Cheers
GavinB.
It is possible but quite complex - what is the ultimate aim of this?
Hi
I need to create a number of variables to use within a crystal report - the number of variables depends on the number of items in a field in a database. If I declare the variables statically then I have to amend the code each time a new record is entered into the database. So being able to do this programmatically is much more ideal.
Cheers
GavinB.
Why not use an array?
I'm not sure if I could do it that way, but I will look into it. I'd still appreciate some pointers as to how to do the variable declaration bit though !
I was going to suggest using reflection but that is for creating .Net classes (and thereby variables) not crystal reports.
That is ok - some of the variables are passed to the report as parameters others are used within the .aspx page to perform a number of calculations.
I think that you can use dynamically resized arrays to acomplish what you want to do...
Still, if you need to create a variable with a specific name you should use the VBCodeProvider Class and check out ICodeCompiler. Basically, you can use that to compile something (a property or public variable) that uses a given variable name and then you need to use reflection to get a hold of that and then use that to pass the variable around. Pretty tedious - like mendhak has already indicated try to steer clear of all that unless it's absolutely necessary.