How much string space can you afford in your Word97SR2 machine?

MY latest efforts fail after 5MB


The code below runs until it generates an "Out Of String Space" (14) error.

You'll be doing me a favour if you report back that you get more than 8MB.

I'd also be interested to hear from you the value at which your swap file kicks in. If I'm very quiet, I can hear drive H: wake up at 4MB and start to hum after 5MB.

The Word status bar will show you the progress, and your last highest value will be in c:temp.

Regardless of the results, I know I'll have to change my ways. I can't really expect to have every character of ASCII text and VBA code rolled into a single string variable in Word97; I'm going to have to devise a disk-based library. OTOH if I'm the only one failing at 8MB and the rest of you bail out after, say, 50M, then I know that there's something weird with my system.

If this turns into a PhD thesis, let's identify some basic parameters early on, such as version of Windows, MB RAM on board, size of sawp file etc.

<pre>Sub MaxStringSpace()

Dim intFile As Integer
intFile = FreeFile

Dim str1 As String
str1 = ""

Dim intIncrement As Integer
intIncrement = 30000

While True
str1 = str1 & String$(intIncrement, "*")
Open "c:temperase.txt" For Output As #intFile
Application.StatusBar = strFmtDec(Len(str1))
Write #intFile, Len(str1)
Close #intFile

End Sub
Public Function strFmtDec(lngValue, Optional intPlaces As Integer = 0) As String
' Procedure : strFmtDec
' Description: Simple format of a numeric value.
' Copyright: Chris Greaves Inc.
' Inputs: Variant value, INTEGER number of decimal places
' Returns: STRING.
' Assumes: None.
' Side Effects: None.
' Tested: By the calls below.

Dim strFmt As String
strFmt = "#,##0"
If intPlaces < 0 Then
If intPlaces = 0 Then
strFmtDec = Format(lngValue, strFmt)
strFmt = strFmt & "." & String(intPlaces, "0")
strFmtDec = Format(lngValue, strFmt)
End If
End If
'Sub TESTstrFmtDec()
'MsgBox strFmtDec(1234567) ' 1,234,567
'MsgBox strFmtDec(1234567, -2) '
'MsgBox strFmtDec(1234567, 0) ' 1,234,567
'MsgBox strFmtDec(1234567, 4) ' 1,234,567.0000
'MsgBox strFmtDec(-1234567) ' -1,234,567
'End Sub
End Function

Here's my c:temperase.txt: