Microsoft KB Archive/37029

= &quot;Invalid Constant&quot; Using Variable for Length of Fixed String =

Article ID: 37029

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q37029



SUMMARY
The length of a fixed-length character string variable must be specified as a integer constant or as a CONST integer constant. The run-time error &quot;Invalid Constant&quot; results if the number in a &quot;STRING * number&quot; clause of a DIM or REDIM statement is a variable, or a constant of a non-integer type.

The length of a fixed-length string must not be negative. A fixed-length string must have a length of at least one.

This information applies to Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50, to Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2, and to Microsoft Basic PDS Version 7.00 for MS-DOS and MS OS/2.



MORE INFORMATION
QuickBasic versions earlier than Version 4.00 do not support fixed-length string variables.

The following is a code example: 'This program will correctly give &quot;Invalid Constant&quot; when x is replaced 'by y or z in the DIM statement. DEFINT A-Z CONST x = 11 CONST y = 11.0 z = 11 DIM a AS STRING * x  a = &quot;hello there&quot; PRINT a  END

Additional query words: QuickBas BasicCom

Keywords: KB37029

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.