indyng
asked on
Why am I getting this error?
Hi Experts,
I have:
Set rs=Server.CreateObject("AD ODB.Record set")
' Query InitializMonths from "FMA Tracker Manager" table
strSQL = "SELECT [FMA Tracker Manager].InitializMonths FROM [FMA Tracker Manager]"
rs.Open strSQL,conn
InitMonths = rs("InitializMonths")
Dim data0(InitMonths)
Dim data1(InitMonths)
Dim labels(InitMonths)
The error is:
Error Type:
Microsoft VBScript compilation (0x800A0402)
Expected integer constant
/intermodal/load_record/Al lowancesBy Emitter.as p, line 64, column 10
Dim data0(InitMonths)
---------^
How can I fix this?
Thanks
I have:
Set rs=Server.CreateObject("AD
' Query InitializMonths from "FMA Tracker Manager" table
strSQL = "SELECT [FMA Tracker Manager].InitializMonths FROM [FMA Tracker Manager]"
rs.Open strSQL,conn
InitMonths = rs("InitializMonths")
Dim data0(InitMonths)
Dim data1(InitMonths)
Dim labels(InitMonths)
The error is:
Error Type:
Microsoft VBScript compilation (0x800A0402)
Expected integer constant
/intermodal/load_record/Al
Dim data0(InitMonths)
---------^
How can I fix this?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think I know why
what is the value of rs("InitializMonths").Valu e ?
the subscript out of range means that the array data0 is not size to 13 items.
the subscript out of range means that the array data0 is not size to 13 items.
How about this ?
Dim data0(CInt(InitMonths))
Dim data0(CInt(InitMonths))
And this:
data0(i -1) = rs("SumOfThisMonthsCalcAll wnce")
data0(i -1) = rs("SumOfThisMonthsCalcAll
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can't use a variable for an array size in a Dim statement.
You have to do
Dim data0()
{...code...}
Redim data0(InitMonths)
You have to do
Dim data0()
{...code...}
Redim data0(InitMonths)
Um isn't that what I just said int he previous post?
I see no reason to close and refund.
The question was:
"The error is:
Error Type:
Microsoft VBScript compilation (0x800A0402)
Expected integer constant
/intermodal/load_record/Al lowancesBy Emitter.as p, line 64, column 10
Dim data0(InitMonths)
---------^
How can I fix this?
"
My answer was that you can't use a variable to size the array if you use Dim you have to use ReDim.
Here are two links with source to prove the answer:
http://lonecrow.net/VariableSizeArray.asp
http://lonecrow.net/VariableSizeArraywitherror.asp
The questioner then moved on to the next issue which is that the value he wanted to use was larger then the size of the array he created. Someone was helping him with his next issue and now he wants it closed?
I think people would still be willing to continue to help if he left it open. Or they can select an answer and close it.
Not trying to be petty or anything but their first question was answered and then they moved onto another question and now wants a refund? Sounds a bit off to me.
The question was:
"The error is:
Error Type:
Microsoft VBScript compilation (0x800A0402)
Expected integer constant
/intermodal/load_record/Al
Dim data0(InitMonths)
---------^
How can I fix this?
"
My answer was that you can't use a variable to size the array if you use Dim you have to use ReDim.
Here are two links with source to prove the answer:
http://lonecrow.net/VariableSizeArray.asp
http://lonecrow.net/VariableSizeArraywitherror.asp
The questioner then moved on to the next issue which is that the value he wanted to use was larger then the size of the array he created. Someone was helping him with his next issue and now he wants it closed?
I think people would still be willing to continue to help if he left it open. Or they can select an answer and close it.
Not trying to be petty or anything but their first question was answered and then they moved onto another question and now wants a refund? Sounds a bit off to me.
I agree
point split: angelIIII , chisholmd
agree
well, ee_ai_construct, that is not the point split I suggestion, or what? 8-)
thanks
ASKER
Dim i
Dim data0()
Dim data1()
Dim labels()
Dim arrMonth(12)
Set rs=Server.CreateObject("AD
' Query InitializMonths from "FMA Tracker Manager" table
strSQL = "SELECT [FMA Tracker Manager].InitializMonths FROM [FMA Tracker Manager]"
rs.Open strSQL,conn
i = rs("InitializMonths").Valu
ReDim data0(i)
ReDim data1(i)
ReDim labels(i)
Response.Write "InitializMonths:" & rs("InitializMonths") & "<br>"
Still doesn't work
I now get the following error:
Error Type:
Microsoft VBScript runtime (0x800A0009)
Subscript out of range: '13'
/intermodal/load_record/Gr
Line 41 is:
data0(i) = rs("SumOfThisMonthsCalcAll