MsOf10 split function and arrays-VBForums
Results 1 to 4 of 4

Thread: split function and arrays

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Posts
    70

    split function and arrays

    Hi there. I'm applying this function in Access 2010 so I've added the question to the Office Development thread even though it may apply elsewhere.

    I have some code.

    It splits some strings and feeds the results into a database table using the split function.
    When I loop through the data I re-use the same name for the array, eg. splitstring = split(mystring,",")

    Should I be erasing the splitstring array after every loop iteration? or does the re-use of the same array name automatically redim the array?

    Reason I ask is after I get through some 2000+ iterations the code starts slowing down and I am wondering whether it's due to incrasing memory usage (through non-erasure of arrays) or it's just the strings I'm splitting?

    Hope that made sense.

    Cheers

  2. #2
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,422

    Re: split function and arrays

    I don't believe you'd need to clear the array in each loop. I would think that would slow things down even more. Maybe you could post your code so we could see if there is anything else that might be the cause of the slow down?

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,034

    Re: split function and arrays

    while i would agree with bryce, i remember reading somewhere recently, where clearing arrays could help with some issues

    anyway it is very simple to do it to test if it helps
    erase splitstring
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Posts
    70

    Re: split function and arrays

    thanks for the answers guys.

    I was debugging overnght and found that in fact i wasn't the arrays but the database insertion method I was using.

    I created a recordset everytime i wanted to append to the table. Once the table got to >60000 records, the act of creating the recordset was the process that was slowing down.

    I now use a db.execute query step to insert the information and whilst it is slower at first, it is consistent and access speed does not slow once you get to >60000 records so overall gains are better.

    Cheers

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.