KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q129802: PRB: Can’t Have Fixed Length Strings >32K in 32-bit Windows

Article: Q129802
Product(s): Microsoft Visual Basic for Windows
Version(s): WINDOWS:4.0
Operating System(s): 
Keyword(s): kberrmsg kbprogramming kbVBp400 kb32bitOnly
Last Modified: 11-JAN-2001

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Visual Basic Standard Edition, 32-bit, for Windows, version 4.0 
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows, version 4.0 
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows, version 4.0 
-------------------------------------------------------------------------------

SYMPTOMS
========

Attempting to create fixed-length strings within a user-defined type in the
32-bit version of Microsoft Visual Basic version 4.0 generates this error:

  "Fixed or static data can't be larger than 64K"

CAUSE
=====

Because 32-bit Microsoft Visual Basic uses Unicode to store strings and Unicode
requires two bytes per character in a string, fixed-length strings take twice as
many bytes of storage as the 16-bit versions of Visual Basic. If you assign or
dimension more that 32K characters to a string, the storage actually exceeds the
64K limit of Visual Basic user-defined types.

RESOLUTION
==========

Larger strings can be assigned to string elements of user-defined types by using
variable-length strings instead of fixed-length strings.

STATUS
======

This behavior is by design.

MORE INFORMATION
================

Steps to Reproduce Behavior
---------------------------

1. Start a new project in Visual Basic. Form1 is created by default.

2. Add a code module (Module1) to your project by choosing Module from the
  Insert menu.

3. Add the following code to the General Declarations section of Module1:

        Type MyType
           MyString As String * 33000
        End Type

4. Start the program by choosing Start from the Run menu or by pressing the F5
  key. You should see the following run-time error message:

  "Fixed or static data can't be larger than 64K"

Additional query words: double byte character set dbcs

======================================================================
Keywords          : kberrmsg kbprogramming kbVBp400 kb32bitOnly 
Technology        : kbVBSearch kbAudDeveloper kbVB400Search kbVB400
Version           : WINDOWS:4.0
Issue type        : kbprb

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.