Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 01-15-2014, 08:20 PM
omahadivision omahadivision is offline Is there a way to delete the beginning part of an array so it doesn't overflow? Windows 7 32bit Is there a way to delete the beginning part of an array so it doesn't overflow? Office 2007
Novice
Is there a way to delete the beginning part of an array so it doesn't overflow?
 
Join Date: Oct 2012
Posts: 28
omahadivision is on a distinguished road
Default

I also thought that I would post the code in case anyone else in the future tries a similar method:

Counts whole file (megacount is the new counter I made to create the entire file)

Code:
Do While Not fo.AtEndOfStream 'Counts all lines
fo.readline
Megacount = Megacount + 1
Loop
Close and reopen:

Code:
fo.Close
Set fo = fso.OpenTextFile(FName, 1)
Getting the end of the array:

Code:
countagain=0 'This is required to count what line the file is on during the second run
Count=0

If Megacount < 10000 Then 'For small files under 10000 lines, entire array is imported
       Do While Not fo.AtEndOfStream 'Puts the rest of the file into an array after title line
       Count = Count + 1
       ReDim Preserve AllArray(Count)
       AllArray(Count) = fo.readline
       Loop
       
    Else 'Bigger files above 10000 lines.  'Cycles through beginning of file without putting anything in array
        Do Until Countagain > Megacount - 9999
        fo.readline
        Countagain = Countagain + 1
        Loop
        
        Do While Not fo.AtEndOfStream 'Actually puts things in array, Count is the array counter
        ReDim Preserve AllArray(Count)
        AllArray(Count) = fo.readline
        Count = Count + 1
        Loop
 End If
The advantage of using three counters (Count, countagain, megacount) instead of two is that the first imported line (10,000 from end of file) is in AllArray(0), and the last line is in AllArray(Count)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to delete the beginning part of an array so it doesn't overflow? Delete bookmark which doesn't have a name rarulkumar Word VBA 2 04-19-2013 03:19 AM
Control direction of resizing textarea on overflow noodle PowerPoint 0 03-31-2013 04:52 AM
Is there a way to delete the beginning part of an array so it doesn't overflow? Convert String Array to Integer Array from a User Input? tinfanide Excel Programming 4 12-26-2012 08:56 PM
Is there a way to delete the beginning part of an array so it doesn't overflow? Files beginning ~$ RobinW Word 1 06-28-2012 05:35 PM
Is there a way to delete the beginning part of an array so it doesn't overflow? Before the table but after beginning of doc? Jaymond Flurrie Word VBA 2 08-16-2011 06:27 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:18 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft