[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

Why am I getting this error?

Hi Experts,

I have:

Set rs=Server.CreateObject("ADODB.Recordset")

' 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/AllowancesByEmitter.asp, line 64, column 10
Dim data0(InitMonths)
---------^

How can I fix this?

Thanks
0
indyng
Asked:
indyng
  • 6
  • 4
  • 2
  • +2
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Make this line like this:
InitMonths = rs("InitializMonths").Value
0
 
indyngAuthor Commented:
This is what I have:

Dim i
Dim data0()
Dim data1()
Dim labels()

Dim arrMonth(12)

Set rs=Server.CreateObject("ADODB.Recordset")

' Query InitializMonths from "FMA Tracker Manager" table
strSQL = "SELECT [FMA Tracker Manager].InitializMonths FROM [FMA Tracker Manager]"
rs.Open strSQL,conn

i = rs("InitializMonths").Value

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/Graph_AllowUsage_RTM_All.asp, line 41

Line 41 is:

  data0(i) = rs("SumOfThisMonthsCalcAllwnce")
0
 
indyngAuthor Commented:
I think I know why
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what is the value of   rs("InitializMonths").Value ?

the subscript out of range means that the array data0 is not size to 13 items.
0
 
vincent_figoCommented:
How about this ?

Dim data0(CInt(InitMonths))
0
 
vincent_figoCommented:
And this:

data0(i -1) = rs("SumOfThisMonthsCalcAllwnce")
0
 
chisholmdCommented:
I think if you want to initialize an array size using a variable you have to use redim not dim.

Try this instead:
     ReDim data0(InitMonths)
0
 
CyrexCore2kCommented:
You can't use a variable for an array size in a Dim statement.

You have to do

Dim data0()

{...code...}

Redim data0(InitMonths)
0
 
chisholmdCommented:
Um isn't that what I just said int he previous post?
0
 
chisholmdCommented:
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/AllowancesByEmitter.asp, 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.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I agree
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
point split: angelIIII , chisholmd
0
 
chisholmdCommented:
agree
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
well, ee_ai_construct, that is not the point split I suggestion, or what? 8-)
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 6
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now