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.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
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.
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,109
Members
448,548
Latest member
harryls

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top