Getting Subscript out of range error in ASP, COM & VB application

dileepav
dileepav used Ask the Experts™
on
Hi Experts,

I am getting the following error in my application please help.

HRW_Export_TCP2008_1 error '800a0009'

Subscript out of range

/Empserv/TotalComp/Export.asp, line 88


thanks
Dileep.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Looks like you are using a non-existing index of an existing array.


For example
MyArray(0) = "bla"
MyArray(1) = "blabla"
MyArray(2) = "blablabla"

and the code is trying to use MyArray(3), which does not exist.

Author

Commented:
here is the place I am getting this error:
===============================

Select Case CStr(vExport(C_EXPORT_PLAN))      
            Case "Merit"
                  blnRetVal = objXL.ExportMerit(Session("Pword"),vExport(C_EXPORT_PLAN),vDetail,C_TCP_EXPORT_DIR,vExport(C_EXPORT_FILE_NAME),vExport(C_EXPORT_FREQUENCY))
                  'vExport(C_EXPORT_FREQUENCY))
                        'Response.Write "Value of blnRetVal is " + blnRetVal + "<BR>"

vDetail is a two dimensional array, how can i see the content in this two dimensional array? please help....., I just wanted to write the array on the web page.

thanks
Dileep

Author

Commented:
THe issue is still there... please help
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Author

Commented:
Microsoft VBScript runtime error '800a0009'

Subscript out of range: '42'

/Empserv/TotalComp/Export.asp, line 94

Author

Commented:
Hi Sybe,

But how can Imake sure that, the code is not using that index?

thanks
Dileep
Commented:
I am not sure. To be honest, the code you posted is not very helpful, I do not see a possible cause for the error there. It refers to an unclear method in an unknown object ("objXL.ExportMerit")

Working with two-dimensional arrays is tricky, because the dimension are counter-intuitive (for me at least).

Author

Commented:
Hi Sybe,

here is the full code of the Export.asp, please guide me.

thanks
Dileep
<%@ Language=VBScript %>
<%option explicit
Response.CacheControl = "no-cache" 
Response.AddHeader "Pragma","no-cache" 
Response.Expires = -1 
Response.Buffer = True
'On error resume next

If Session("User") = "" then
	Response.Write "<html><head><title>Performance Partnership Timeout</title></head><body><br>"
	Response.Write "<div align=center style='color:red'><h2>Your Performance Partnership Session has timed out!</div></h2><hr><br><br><h3>Follow these instructions to reload login page:<br>after closing this window, refresh the <i>prior</i> window by pressing F5 on a PC or, if you are using a Mac, selecting the 'Refresh' option from the menu.<br><br></body></html>"
	Response.End 
ElseIf Application("Locked")=True Then
	Response.Write "<html><head><title>Performance Partnership Unavailable</title></head><body><br><h1><div align=center style='color:red'>Do not close this window!</div></h1><hr><br>"
	Response.Write "<h2>The Performance Partnership System is unavailable for a few minutes.</h2><br><h3><span style='color:red'>When the system is again available you will resume <b>exactly where you left off without any loss of information only if you follow the instructions below.</span></h3></b><h3><hr><br>1. Refresh this window by pressing F5 on a PC or, if you are using a Mac, selecting the 'Refresh' option from the menu.<br><br>2. Click 'Retry' if prompted.<br><br>3. Repeat steps 1 and 2 at least every few minutes until the system becomes available.<br></h2></body></html>"
	Response.End 
	
End if

Dim vExport,lngRandom,blnRetVal,obj,vDetail,objXL
%><html>
<head>
<!-- #INCLUDE FILE="../Common/ServerScripts/header.asp" -->
<!-- #INCLUDE FILE="../Common/Constants/Env.inc" -->
<!-- #INCLUDE FILE="../Common/ServerScripts/Navigation.asp" -->
<script LANGUAGE="JavaScript" SRC="../Common/ClientScripts/Common.js"></script>
<title>Export</title>
</head>
<body oncontextmenu="return true"><%

'Load the header
Call Load_Basic_Header("Export")

if Request.QueryString("Type") = "Select" Then
	Response.Write "<BR>Select an organization before exporting."
	Response.End 
end if

Response.write "<span id='sGetting' class='tSubHeadTxt'>Creating an Excel spreadsheet from the active selection....</span>"
Response.Flush 

vExport=Session("Export")
If IsEmpty(vExport) Then
		Response.Write "<br><span class='tSubHeadTxt'>This selection is not currently able to be exported</span>"
Else
	Response.Write("<br />")
        Response.Write("Export Functionality Started.")
	Randomize
	lngRandom = int((9000000000 - 1000000000 + 1) * Rnd + 1000000000)
	vExport(C_EXPORT_FILE_NAME)=CStr(vExport(C_EXPORT_PLAN)) & "_" & session.SessionID & "_" & lngRandom

	Set obj = Server.CreateObject("HRW_Execute.CExecute") 
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write vExport(C_EXPORT_QUERY)
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write(C_EXPORT_FIELDS)
		vDetail = obj.SelectRows(C_DB_NAME, C_RDAHR_ID,C_RDAHR_PW, vExport(C_EXPORT_QUERY), vExport(C_EXPORT_FIELDS))
	Set obj = Nothing
	Set objXL = CreateObject(C_TCP_EXPORT) 
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write(C_EXPORT_PLAN)
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write("First Time") + "<BR />"
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write (vExport(C_EXPORT_FILE_NAME) + "<BR />")
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write (vExport(c_EXPORT_PLAN) + "<BR />")
	Response.Write("<br />")
        Response.Write("<br />")
	vExport(C_EXPORT_FILE_NAME)=CStr(vExport(C_EXPORT_PLAN)) & "_" & session.SessionID & "_" & lngRandom
	'Response.Write("<br />")
        'Response.Write("<br />")
 	Response.Write("Second Time") + "<BR />"
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write (vExport(C_EXPORT_FILE_NAME) + "<BR />")
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write(CStr(vExport(C_EXPORT_PLAN)))
	Response.Write(CStr(Session("Pword")))
	Response.Write(C_EXPORT_FIELDS)
	'Response.Write(vDetail(0,0))
        Response.Write(C_TCP_EXPORT_DIR)
        Response.Write(vExport(C_EXPORT_FILE_NAME))
	Response.Write(vExport(C_EXPORT_FREQUENCY))
	Dim i,j
	For i = 0 To ubound(vDetail,2)
		For j = 0 To ubound(vDetail,2)
 			Response.Write("The number is " & vDetail(i,j) & "<br />")
	Next
	Next

	Select Case CStr(vExport(C_EXPORT_PLAN))	
		Case "Merit"
			blnRetVal = objXL.ExportMerit(Session("Pword"),vExport(C_EXPORT_PLAN),vDetail,C_TCP_EXPORT_DIR,vExport(C_EXPORT_FILE_NAME),vExport(C_EXPORT_FREQUENCY))
			'vExport(C_EXPORT_FREQUENCY))
                        'Response.Write "Value of blnRetVal is " + blnRetVal + "<BR>"
		Case "VCP"
			blnRetVal = objXL.ExportMIP(Session("Pword"),vExport(C_EXPORT_PLAN),vDetail,C_TCP_EXPORT_DIR,vExport(C_EXPORT_FILE_NAME))
			'Response.Write blnRetVal + "<BR>"
			'Response.Write "Value of blnRetVal is " + blnRetVal + "<BR>"		
		Case "AIP"
			blnRetVal = objXL.ExportAIP(Session("Pword"),vExport(C_EXPORT_PLAN),vDetail,C_TCP_EXPORT_DIR,vExport(C_EXPORT_FILE_NAME))		
			'Response.Write blnRetVal + "<BR>"
			'Response.Write "Value of blnRetVal is " + blnRetVal + "<BR>"
		Case Else
			Response.Write "<br><span class='tSubHeadTxt'>The " & vExport(C_EXPORT_PLAN) & " plan is not currently able to be exported</span>"
			Set objXL = nothing
			Response.End  
	End Select
	Set objXL = nothing

	If blnRetVal Then
		%><br><br><span class='tSubHeadTxt'>A Microsoft Excel spreadsheet has been created with real-time information. This spreadsheet has been protected with your Performance Partnership System password (in lower case). After opening the file, please save it to a local hard drive or floppy disk.</span><br><br>
		<span class='tSubHeadTxt'><A href='../Export/<%= vExport(C_EXPORT_FILE_NAME)%>.xls' target='sshet'><img border="0" SRC="../Common/Images/Report/ExcelIcon.gif" WIDTH="40" HEIGHT="40"></A>Click to open the spreadsheet or right-click for other options.</span><br><%
			
	Else
		Response.Write "<SCRIPT LANGUAGE=javascript>sGetting.innerHTML='An error occurred during spreadsheet creation.<br>Please contact user support.';</SCRIPT>"
		Response.End 
	End If
	
End If
%>
<SCRIPT LANGUAGE=javascript>sGetting.innerHTML="";</SCRIPT>
</body>
</html>

Open in new window

Author

Commented:
Please let me know if you need any more code or any clarification.
Test Developer/Validator
Commented:
It looks to me like you are allowing both i and j to range up to ubound(vDetail,2)

Are you certain that the vDetail array has as many rows as it has columns?

Author

Commented:
Hi Experts,

This issue has been resolved now.

Special thanks to the Admin as well.

thanks
Dil

Author

Commented:
Problem was there with reading the array.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial