
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)")