Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run time error '800a0009' subscript out of range

Status
Not open for further replies.

cfcProgrammer

Programmer
Mar 1, 2006
88
CA
I'm getting an error "run time error '800a0009' subscript out of range", the only explanation I can see is that the array is out of range... but this doesn't seem to be the case. Can anyone help with an explanation for this by reviewing the snipet of code I've included? The line that is causing the error is highlighted.

Code:
sub sItemWriteSharePathsCombo(lvItemId,lvRowId,lvItemTypeId,lvFieldId,lvCurrentPath,lvShareWhat,lvFieldFolderPath,lvOptions)
	' Find out how many folders there are:
	
	dim loRs,lvSql,loRs2,lvValue,lvText,lvNoSharingCurrentPath,lvNoPaths,lvNoLangInSite,lvSiteId,loFs,lvNoSharingThisPath
	dim lvNoRealFieldFolders,lvRealFieldFolders(100),lvRealFieldFoldersIsUsed(100),loFolder,n,lvFolderPath

	Response.Write "<INPUT type=hidden"
	Response.Write " name=F" & lvFieldId & "_ORG " 
	Response.write " value='"&fGetFormDatFromDb(lvCurrentPath)&"'"  
	Response.Write ">"

	set loFs=server.CreateObject("Scripting.FileSystemObject")
	lvNoRealFieldFolders=0
	if loFs.folderExists(lvFieldFolderPath) then
	for each loFolder in loFs.GetFolder(lvFieldFolderPath).SubFolders
	[highlight] lvRealFieldFolders(lvNoRealFieldFolders)=loFolder.name [/highlight]
			lvRealFieldFoldersIsUsed(lvNoRealFieldFolders)=false
			lvNoRealFieldFolders=lvNoRealFieldFolders+1
		next
	end if

Any help would be greatly appreciated. If you need more info I can provide it.

Thanks
cfcprogrammer

cfcProgrammer
 
if this is .net code why aren't you using .net objects? this call should never be made:
Code:
server.CreateObject("Scripting.FileSystemObject")
use the FileInfo and DirectoryInfo objects in the System.IO namespace. I also recommend renaming the variables to something much more human readable. like: idOfFile, or indexOfFile, or dateTheFileShouldExpire. lvRealFieldFolders is cryptic. what is lv? what is meant by real fields? are there fake fields?

this is a code smell
Code:
    Response.Write "<INPUT type=hidden"
    Response.Write " name=F" & lvFieldId & "_ORG "
    Response.write " value='"&fGetFormDatFromDb(lvCurrentPath)&"'"  
    Response.Write ">"
that's what web controls are for. if you don't want to add webcontrols to the page, then at least put this in the markup page
Code:
<INPUT 
   type=hidden 
   name='<%="F" & lvFieldId & "_ORG"%>'
   value='<%=&fGetFormDatFromDb(lvCurrentPath)%>' />

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Hi Jason,

Thank you so much for your comments they are greatly appreciated. I am a new employee to this company, this is the first project I am working on for them. I can't explain to you why the code was written this way or why the naming conventions are the way they are. I am as confused as you are. On top of all that, I am new to .net.

Other than the suggestions that you made regarding the code technique do you have any suggestions on why this error is being generated?

Again, any help is greatly appreciated

cfcprogrammer

cfcProgrammer
 
This issue has been resolved and is considered closed.

cfcProgrammer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top