Microsoft KB Archive/94833

= Array Errors When Call Function in Other Module w/ No Declare =

Article ID: 94833

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft Visual Basic for MS-DOS
 * Microsoft BASIC Professional Development System 7.1
 * Microsoft QuickBasic 4.5 for MS-DOS

-



This article was previously published under Q94833



SUMMARY
If a function called in one module exists in a different module and the calling module does not contain a Declare statement for that function, you can get one of the following error messages:


 * Subscript out of range
 * Type mismatch
 * Array not defined

This is because without the Declare statement, Basic thinks that you are implicitly declaring an array. Because Basic defines 11 elements implicitly in an array, your program may pass over the function without producing an error message. This can happen if you pass one numeric argument between 0 and 10.

To work around this problem, put a Declare for each function in the module where the function is called.



MORE INFORMATION
This may be a problem when converting an application from Visual Basic for Windows to Visual Basic for MS-DOS. It may also be a problem when creating a program in a separate editor and then loading that program into the interpreter environment.

The above mentioned Basic products do not automatically put Declare statements in modules that call functions that exist in a different module, so you can get unexpected results. Basic thinks these Functions are actually arrays, therefore giving an error message or quietly passing by your lines of code.

Additional query words: VBmsdos 1.00

Keywords: KB94833

-

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

© Microsoft Corporation. All rights reserved.