String variable size limit not 2GB?

pbassett

Active Member
Joined
May 5, 2004
Messages
358
My code reads files into a string for processing. Today it broke with the error "Run-time error 7 Out of Memory" on a file with LOF (size) 153,344,779 bytes. This is surprising since strings should be allowed up to 2GB. Previous files were easily read by this command:

Dim strFile As String
strFile = Space(LOF(iFileNo)) ' Set File Buffer Size

strFile is Null with this file, however, and this command results in the Error message:

Get iFileNo, , strFile ' Load text [get error Run-time error 7 Out of Memory]

I would greatly prefer using the Get statement to the alternative of the repeated Line Input and redim into an ever-growing array.
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,732
Office Version
365
Platform
Windows
No idea if it'll make a difference but have you tried declaring the variable as Variant, or not typing it at all.

I'm a little confused though, you say that strFile is Null.:eek:

When is it Null? Before/after you've tried to fill it with spaces.

By the way why are you filling it with spaces and what would be the problem with using Line Input, perhaps a little looping too?

Dealing with string as big as that seems, to me anyway, a bit daunting.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,008
Messages
5,508,754
Members
408,692
Latest member
OptimalKR

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top