|
-
Nov 24th, 2005, 05:42 AM
#1
Thread Starter
New Member
Declare Variable name from variable value
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.
-
Nov 24th, 2005, 05:56 AM
#2
Re: Declare Variable name from variable value
It is possible but quite complex - what is the ultimate aim of this?
-
Nov 24th, 2005, 05:58 AM
#3
Thread Starter
New Member
Re: Declare Variable name from variable value
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.
-
Nov 24th, 2005, 10:14 AM
#4
Re: Declare Variable name from variable value
-
Nov 24th, 2005, 10:17 AM
#5
Thread Starter
New Member
Re: Declare Variable name from variable value
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 !
-
Nov 24th, 2005, 11:53 AM
#6
Re: Declare Variable name from variable value
I was going to suggest using reflection but that is for creating .Net classes (and thereby variables) not crystal reports.
-
Nov 25th, 2005, 01:55 AM
#7
Thread Starter
New Member
Re: Declare Variable name from variable value
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.
-
Dec 9th, 2005, 12:47 PM
#8
Re: Declare Variable name from variable value
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|