SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multi-dimensional array ReDim issues

    IGNORE!!

    I'll leave the post here, because it contains good info for other folk in the future, but the problem was I didn't read the manual properly!!

    It's illegal to attempt to ReDim the first value of a multi-dimensional array.

    Original post below:

    ------------------------------------------------

    Hi all,

    What's wrong with this picture??

    Code:
    Dim tmpArray()
    ReDim tmpArray(0,5)
    
    Do Until objRSMenus.EOF
    
    	SQLString = "SELECT f_alias, f_menutitle FROM t_" & strLangCode & " WHERE f_id = " & objRSMenus("f_page")
    	Set objRSMenuTitles = objConnection.Execute(SQLString)
    
    		tmpArray(UBound(tmpArray),0) = objRSMenus("f_level")
    		tmpArray(UBound(tmpArray),1) = objRSMenus("f_id")
    		tmpArray(UBound(tmpArray),2) = objRSMenus("f_page")
    		tmpArray(UBound(tmpArray),3) = objRSMenus("f_relationship")
    		tmpArray(UBound(tmpArray),4) = objRSMenuTitles("f_alias")
    		tmpArray(UBound(tmpArray),5) = objRSMenuTitles("f_menutitle")
    		'Response.Write tmpArray(i,4)
    	i = i + 1
    	Response.Write tmpArray(UBound(tmpArray),5)
    	Response.Write (UBound(tmpArray)+1)	
    	
    	objRSMenuTitles.Close
    	Set objRSMenuTitles = Nothing
    	
    	ReDim Preserve tmpArray((UBound(tmpArray)+1),5)
    objRSMenus.MoveNext
    Loop
    As you can see, I'm writing some database records in to a multi-dimensional array for later use. It does the first loop fine, but on the second loop I keep getting this at line 61 - the ReDim line:

    Microsoft VBScript runtime error '800a0009'

    Subscript out of range

    /test.asp, line 61
    If I remove Preserve it works, but I need it!

    Grrrr! Am I doing something stupid? So far as I can tell, this should work...

    Cheers,

    G

  2. #2
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It's illegal to attempt to ReDim the first value of a multi-dimensional array.
    You don't want those coding cops after you
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  3. #3
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup - big fine and you loose your Dreamweaver licence...


Bookmarks

Posting Permissions

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