Use a variable name to create an array 
Author Message
 Use a variable name to create an array

Is there a way to Use a variable name to create an array?
I've tried this but it errors every time:

Dim strTable
strTable = "tblPaint"
Eval("Dim arr" & strTable & "()")
Eval("ReDim Preserve arr" & strTable & "(3)")
Eval("arr" & strTable & "(0) = test passed")
MsgBox Eval("arr" & strTable & "(0)")

Thanks in advance.

Bill



Wed, 03 Aug 2005 08:36:39 GMT  
 Use a variable name to create an array

Quote:

> Is there a way to Use a variable name to create an array?
> I've tried this but it errors every time:

> Dim strTable
> strTable = "tblPaint"
> Eval("Dim arr" & strTable & "()")
> Eval("ReDim Preserve arr" & strTable & "(3)")
> Eval("arr" & strTable & "(0) = test passed")
> MsgBox Eval("arr" & strTable & "(0)")

> Thanks in advance.

> Bill

Hi, Bill
I think you want something like this.
The 'test passed' string has to be enclosed in '"' marks.
Echoing/msgboxing the strings you are going to eval/execute is a good way to look at them to verify that they are valid for that
purpose.

I can't explain the technical differences between eval and execute, but I think Joe Earnest posted some good info in the past few
days about it.

Watch out for wrap.

Dim strTable
strTable = "tblPaint"
execute("Dim arr" & strTable & "()")
execute("ReDim Preserve arr" & strTable & "(3)")
execute("arr" & strTable & "(0) = " & chr(34) & "test passed" & chr(34))
MsgBox Eval("arr" & strTable & "(0)")



Wed, 03 Aug 2005 09:52:36 GMT  
 Use a variable name to create an array
Excellent! Thanks very much for your help.

Quote:
>-----Original Message-----




Quote:
>> Is there a way to Use a variable name to create an
array?
>> I've tried this but it errors every time:

>> Dim strTable
>> strTable = "tblPaint"
>> Eval("Dim arr" & strTable & "()")
>> Eval("ReDim Preserve arr" & strTable & "(3)")
>> Eval("arr" & strTable & "(0) = test passed")
>> MsgBox Eval("arr" & strTable & "(0)")

>> Thanks in advance.

>> Bill

>Hi, Bill
>I think you want something like this.
>The 'test passed' string has to be enclosed in '"' marks.
>Echoing/msgboxing the strings you are going to

eval/execute is a good way to look at them to verify that
they are valid for that
Quote:
>purpose.

>I can't explain the technical differences between eval

and execute, but I think Joe Earnest posted some good info
in the past few

- Show quoted text -

Quote:
>days about it.

>Watch out for wrap.

>Dim strTable
>strTable = "tblPaint"
>execute("Dim arr" & strTable & "()")
>execute("ReDim Preserve arr" & strTable & "(3)")
>execute("arr" & strTable & "(0) = " & chr(34) & "test
passed" & chr(34))
>MsgBox Eval("arr" & strTable & "(0)")

>.



Sun, 07 Aug 2005 00:23:15 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Create a dynamic array from set of Session variables

2. Using RedMon environment variables to get original Document Name

3. Problem using a variable for a Theme name

4. Using two values as a variable name

5. Using variables to construct object name paths

6. create a file using system date time in file name

7. using array notation to loop through variables?

8. How to pass vbscript array variable to shared object using ByRef

9. create an array or collection with network numbers or hostnames using scriptomatic

10. UBound returns different result when array is created using Split()

11. create an array or collection with network numbers or hostnames using scriptomatic

12. Creating and environment variable and using it in the same cmd window

 

 
Powered by phpBB® Forum Software