Scrier Posted September 5, 2006 Share Posted September 5, 2006 Well, im probable doing some basic mistake but the weird thing is that it worked before and I havent altered the code so here goes, I get the following error Microsoft VBScript runtime error '800a0009' Subscript out of range: 'UBound' /dev_anj/NIR_search.asp, line 577on row 577for i = 0 to ubound(arrItems,2) arrItems is defined as: dim arrItems() Depending on if I have one of 2 radiobuttons selected he redims it to either ReDim Preserve arrItems(5, ArrIndex) or ReDim Preserve arrItems(4, ArrIndex) now i'm guessing here that it redims the array to 5 although that selection isn't valid, because I didn't get the error with only ReDim Preserve arrItems(4, ArrIndex) Is a good solution to make it 2 different arrays even though I don't populate one of them? Link to comment Share on other sites More sharing options...
aspnetguy Posted September 5, 2006 Share Posted September 5, 2006 I would set a boolean variable based on the ddl selection and populate the correct array based on the boolean.I never liked using redim. Link to comment Share on other sites More sharing options...
Scrier Posted September 6, 2006 Author Share Posted September 6, 2006 I would set a boolean variable based on the ddl selection and populate the correct array based on the boolean.I never liked using redim.Problem is that it's a search function from different tables in a database and depending on where you search a different number of items should be shown (hence 5 or 4 in size and increasing on the dimension for each hit). Link to comment Share on other sites More sharing options...
Scrier Posted September 6, 2006 Author Share Posted September 6, 2006 Ok I totally separated the 2 now so the problem seems to be arritems alone and that I get out of bound for any lbound or ubound function towards it. Even though it says true on a Isarray. I am all out of ideas now because this code worked before I added the second picec of code and now it just decides not to work as an array anymore... Link to comment Share on other sites More sharing options...
Scrier Posted September 6, 2006 Author Share Posted September 6, 2006 Hmm Ill post all code that affects the 2 cases and see if someone can see what might be wrong. dim arrItems(), arrEleItems() elseif request.form("nirselection") = "ele" then ...(generating of the sqlquery) set SQLele = anslut.execute("" & SQLQuery & "") ArrEleIndex = 0 if SQLele.eof then ErrorCode = 2 else do while not SQLele.eof ReDim Preserve arrEleItems(5, ArrEleIndex) arrEleItems(0, ArrEleIndex) = SQLele("reqpro_ref") arrEleItems(1, ArrEleIndex) = SQLele("title") set SQLBuildName = anslut.execute("SELECT prod_ver FROM builds INNER JOIN nir_in_builds ON nir_in_builds.build_id = builds.build_id WHERE nir_element_id='" & SQLele("id") & "'") if not SQLBuildName.eof then strBuild = SQLBuildName("prod_ver") SQLBuildName.movenext do while not SQLBuildName.eof strBuild = strBuild & ", " & SQLBuildName("prod_ver") SQLBuildName.movenext LOOP else strBuild = "-" end if arrEleItems(2, ArrEleIndex) = strBuild set SQLInfoclassName = anslut.execute("SELECT type_name FROM nir_infoclass WHERE id='" & SQLele("infoclass_id") & "'") if not SQLInfoclassName.eof then arrEleItems(3, ArrEleIndex) = SQLInfoclassName("type_name") else arrEleItems(3, ArrEleIndex) = "-" end if if not SQLele("changed_by") = "" then arrEleItems(4, ArrEleIndex) = SQLele("changed_by") else arrEleItems(4, ArrEleIndex) = SQLele("created_by") end if arrEleItems(5, ArrEleIndex) = "<a href=NIR_element.asp?selection=edit&id=" & SQLele("id") & " target=_blank><img src=bilder/edit.gif border=0></a><a href=NIR_element.asp?selection=delete&id=" & SQLele("id") & " target=_blank><img src=bilder/delete.gif border=0></a>" ArrEleIndex = ArrEleIndex + 1 SQLele.movenext LOOP end if end if ...(some things that don't affect the code) for i = 0 to ubound(arrEleItems,2) ... (printing it out to page etc no errors here) next This part works flawless. elseif request.form("nirselection") = "not" then ...(making of sqlquery) set SQLnot = anslut.execute("" & SQLQuery & "") ArrIndex = 0 if SQLnot.eof then ErrorCode = 2 else do while not SQLnot.eof ReDim Preserve arrItems(4, ArrIndex) arrItems(0, ArrIndex) = SQLnot("tag") set SQLBuildName = anslut.execute("SELECT prod_ver FROM builds where build_id='" & SQLnot("build_id") & "'") arrItems(1, ArrIndex) = SQLnot("name") arrItems(2, ArrIndex) = SQLBuildName("prod_ver") if not request.form("infoclass") = "dog_aae" then arrItems(3, ArrIndex) = SQLnot("valid_for") else arrItems(3, ArrIndex) = "-" end if arrItems(4, ArrIndex) = "<a href=NIR_element.asp?selection=new&reqpro_ref=" & SQLnot("tag") & "&infoclass=" & request.form("infoclass") & "&title=" & SQLnot("name") & "&user=" & inloggad & " target=_blank><img src=bilder/new.gif border=0></a>" ArrIndex = ArrIndex + 1 SQLnot.movenext LOOP end if end if ...(some general info not intresting to the cause) for i = 0 to ubound(arrItems,2) <- HERE be tha error >_< ...(writing out items from the array) next This part worked flawless before I added the code above and now gives me a Microsoft VBScript runtime error '800a0009' Subscript out of range: 'UBound' /dev_anj/NIR_search.asp, line 606error and line 606 is the for i = 0 to ubound(arrItems,2)I had arrItems for both in the start and then the top one worked then I added one for each but still gives ubound or lbound error. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now