Can anybody help with my array code

Results 1 to 2 of 2

Thread: Can anybody help with my array code

  1. #1
    Join Date
    Dec 1969

    Default Can anybody help with my array code

    Hi, i have the folllowing code to check if a value stored in a file is set to yes/no if the file is active it should Redim Preserve my array and store the relevant details into the new array listing but i cannot figure out why it is not working. My error message is included at the end of this message. Any help will be greatly appreciated.<BR><BR><BR> comCnt = 0<BR> Set folderObj = fileSysObj.GetFolder(Server.MapPath("Categories/" & thePath2Fol)) <BR> For Each x In folderObj.Files<BR> If Left(x.Name, 7) = "comment" Then<BR> Set folderObj2 = fileSysObj.OpenTextFile(Server.MapPath("Categories/" & thePath2Fol & x.Name))<BR> commConts = folderObj2.ReadAll<BR> chkActive = GetFileMetaTag("&#060;meta name=""Active"" content=""", """&#062;", commConts)<BR> If chkActive = "yes" Then<BR> Response.Write(x.Name & " is active - Counter = " & comCnt)<BR> Redim Preserve usersComments(comCnt,3)<BR> Response.Write(" Created Array Listing -")<BR> usersComments(comCnt,0) = GetFileMetaTag("&#060;meta name=""Name"" content=""", """&#062;", commConts)<BR> usersComments(comCnt,1) = GetFileMetaTag("&#060;meta name=""Place"" content=""", """&#062;", commConts)<BR> usersComments(comCnt,2) = GetFileMetaTag("&#060;meta name=""Description"" content=""", """&#062;", commConts)<BR> usersComments(comCnt,3) = GetFileMetaTag("&#060;meta name=""Comment"" content=""", """&#062;", commConts)<BR> comCnt = comCnt + 1 <BR> Response.Write(" new Counter = " & comCnt)<BR> End If<BR> End If <BR> Next<BR><BR><BR><BR><BR>when i view the page i get this error<BR><BR>comment2.txt is active - Counter = 0 Created Array Listing - new Counter = 1<BR>comment3.txt is active - Counter = 1 <BR>Microsoft VBScript runtime error &#039;800a0009&#039; <BR><BR>Subscript out of range <BR><BR>viewDetails.asp, line 70 <BR>

  2. #2
    Join Date
    Dec 1969

    Default Check out the documentation...

    ...for ReDim Preserve on the Microsoft website:<BR><BR>You can only use ReDim Preserve when you change the LAST array dimension.<BR><BR>Oliver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts