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

ID: Q94833


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for MS-DOS, version 1.0
  • Microsoft BASIC Professional Development System (PDS) for MS-DOS, version 7.1
  • Microsoft QuickBASIC for MS-DOS, version 4.5


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 :
Version : MS-DOS:1.0,4.5; :7.1
Platform : MS-DOS
Issue type :


Last Reviewed: December 10, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.