"Out of String Space" in VB Toolkit Setup Routine

ID Number: Q85155

1.00

WINDOWS

Summary:

If you try to copy a file using the Setup routines provided with

Microsoft Professional Toolkit for Visual Basic version 1.0 and the

the source file is just under a 64K boundary, you will get an "Out of

String Space" error. This occurs because of the way Visual Basic

handles variable-length strings.

This information applies to Microsoft Professional Toolkit for

Microsoft Visual Basic programming system version 1.0 for Windows.

More Information:

When Visual Basic makes the following two assignments

FileData = String$(32500, 32)

FileData = String$(32767, 32)

the data from the first assignment is not removed from memory until

the memory space for the second allocation is obtained. Setup has a

problem with this because when your file is just under a 64K segment

size, there is not enough memory in the segment to make the second

allocation because of other local variable length strings.

In the Setup example provided with the Professional Toolkit in the

global code module SETUP1.BAS, locate the subprogram CopyFile. About

15 lines from the bottom of this subprogram, find the following

assignment:

FileData = String$(BlockSize, 32)

Because BlockSize is equal to 32767 in this assignment, if the

following previous assignment (about six lines up)

FileData = String$(LeftOver, 32)

was near the 32767 mark, you will get the error discussed above. To

avoid this error, simply add the following line ABOVE the BlockSize

assignment:

FileData = ""

This will free up the string space, thus ensuring the successful

completion of the assignment:

FileData = String$(BlockSize, 32)

Additional reference words: 1.00